day10机器学习的全流程

@浙大疏锦行
1.读取数据

import pandas as pd
import pandas as pd    #用于数据处理和分析,可处理表格数据。
import numpy as np     #用于数值计算,提供了高效的数组操作。
import matplotlib.pyplot as plt    #用于绘制各种类型的图表# 设置中文字体(解决中文显示问题)
plt.rcParams['font.sans-serif'] = ['SimHei']  # Windows系统常用黑体字体
plt.rcParams['axes.unicode_minus'] = False    # 正常显示负号
data = pd.read_csv('data.csv')    #读取数据
print("数据基本信息:")
data.info()
print("\n数据前5行预览:")
print(data.head())
数据基本信息:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 7500 entries, 0 to 7499
Data columns (total 18 columns):#   Column                        Non-Null Count  Dtype  
---  ------                        --------------  -----  0   Id                            7500 non-null   int64  1   Home Ownership                7500 non-null   object 2   Annual Income                 5943 non-null   float643   Years in current job          7129 non-null   object 4   Tax Liens                     7500 non-null   float645   Number of Open Accounts       7500 non-null   float646   Years of Credit History       7500 non-null   float647   Maximum Open Credit           7500 non-null   float648   Number of Credit Problems     7500 non-null   float649   Months since last delinquent  3419 non-null   float6410  Bankruptcies                  7486 non-null   float6411  Purpose                       7500 non-null   object 12  Term                          7500 non-null   object 13  Current Loan Amount           7500 non-null   float6414  Current Credit Balance        7500 non-null   float6415  Monthly Debt                  7500 non-null   float6416  Credit Score                  5943 non-null   float6417  Credit Default                7500 non-null   int64  
dtypes: float64(12), int64(2), object(4)
memory usage: 1.0+ MB数据前5行预览:Id Home Ownership  Annual Income Years in current job  Tax Liens  \
0   0       Own Home       482087.0                  NaN        0.0   
1   1       Own Home      1025487.0            10+ years        0.0   
2   2  Home Mortgage       751412.0              8 years        0.0   
3   3       Own Home       805068.0              6 years        0.0   
4   4           Rent       776264.0              8 years        0.0   Number of Open Accounts  Years of Credit History  Maximum Open Credit  \
0                     11.0                     26.3             685960.0   
1                     15.0                     15.3            1181730.0   
2                     11.0                     35.0            1182434.0   
3                      8.0                     22.5             147400.0   
4                     13.0                     13.6             385836.0   Number of Credit Problems  Months since last delinquent  Bankruptcies  \
0                        1.0                           NaN           1.0   
1                        0.0                           NaN           0.0   
2                        0.0                           NaN           0.0   
3                        1.0                           NaN           1.0   
4                        1.0                           NaN           0.0   Purpose        Term  Current Loan Amount  \
0  debt consolidation  Short Term           99999999.0   
1  debt consolidation   Long Term             264968.0   
2  debt consolidation  Short Term           99999999.0   
3  debt consolidation  Short Term             121396.0   
4  debt consolidation  Short Term             125840.0   Current Credit Balance  Monthly Debt  Credit Score  Credit Default  
0                 47386.0        7914.0         749.0               0  
1                394972.0       18373.0         737.0               1  
2                308389.0       13651.0         742.0               0  
3                 95855.0       11338.0         694.0               0  
4                 93309.0        7180.0         719.0               0  
data = pd.read_csv('data.csv')    #读取数据
print("数据基本信息:")
data.info()
print("\n数据前5行预览:")
print(data.head())

2.数据清洗
清洗object
清洗数值型对象

处理object

# 先筛选字符串变量 
discrete_features = data.select_dtypes(include=['object']).columns.tolist()
discrete_features
['Home Ownership', 'Years in current job', 'Purpose', 'Term']
# 依次查看内容
for feature in discrete_features:print(f"\n{feature}的唯一值:")print(data[feature].value_counts())
Home Ownership的唯一值:
Home Ownership
Home Mortgage    3637
Rent             3204
Own Home          647
Have Mortgage      12
Name: count, dtype: int64Years in current job的唯一值:
Years in current job
10+ years    2332
2 years       705
3 years       620
< 1 year      563
5 years       516
1 year        504
4 years       469
6 years       426
7 years       396
8 years       339
9 years       259
Name: count, dtype: int64Purpose的唯一值:
Purpose
debt consolidation      5944
other                    665
home improvements        412
business loan            129
buy a car                 96
medical bills             71
major purchase            40
take a trip               37
buy house                 34
small business            26
wedding                   15
moving                    11
educational expenses      10
vacation                   8
renewable energy           2
Name: count, dtype: int64Term的唯一值:
Term
Short Term    5556
Long Term     1944
Name: count, dtype: int64

进行字典映射

# Home Ownership 标签编码
home_ownership_mapping = {'Own Home': 1,'Rent': 2,'Have Mortgage': 3,'Home Mortgage': 4
}
data['Home Ownership'] = data['Home Ownership'].map(home_ownership_mapping)# Years in current job 标签编码
years_in_job_mapping = {'< 1 year': 1,'1 year': 2,'2 years': 3,'3 years': 4,'4 years': 5,'5 years': 6,'6 years': 7,'7 years': 8,'8 years': 9,'9 years': 10,'10+ years': 11
}
data['Years in current job'] = data['Years in current job'].map(years_in_job_mapping)# Purpose 独热编码,记得需要将bool类型转换为数值
data = pd.get_dummies(data, columns=['Purpose'])
data2 = pd.read_csv("data.csv") # 重新读取数据,用来做列名对比
list_final = [] # 新建一个空列表,用于存放独热编码后新增的特征名
for i in data.columns:if i not in data2.columns:list_final.append(i) # 这里打印出来的就是独热编码后的特征名
for i in list_final:data[i] = data[i].astype(int) # 这里的i就是独热编码后的特征名# Term 0 - 1 映射
term_mapping = {'Short Term': 0,'Long Term': 1
}
data['Term'] = data['Term'].map(term_mapping)
data.rename(columns={'Term': 'Long Term'}, inplace=True) # 重命名列

处理数值型对象

# 缺失值填补
# 异常值处理
continuous_features = data.select_dtypes(include=['int64', 'float64']).columns.tolist()  #把筛选出来的列名转换成列表# 连续特征用中位数补全
for feature in continuous_features:     mode_value = data[feature].mode()[0]            #获取该列的众数。data[feature].fillna(mode_value, inplace=True)          #用众数填充该列的缺失值,inplace=True表示直接在原数据上修改。

这个警告信息是来自Pandas库,它指出了在将来的Pandas版本中(3.0及以后),使用inplace=True参数进行就地修改的方式将会发生变化。具体到你的代码,问题出现在尝试使用fillna方法并设置inplace=True来直接在原DataFrame上修改数据。
问题原因
在Pandas中,当你通过类似data[feature]的方式访问DataFrame的列时,实际上得到的是该列的一个视图(view)或副本(copy)。直接在这个视图或副本上调用fillna方法并设置inplace=True,并不会改变原始DataFrame,因为中间对象(即data[feature])总是表现为一个副本。
解决方案
根据警告信息中的建议,你可以采用以下两种方式之一来解决这个问题:
不使用inplace=True:
直接将fillna的结果赋值回原DataFrame的相应列。这是最简单的解决方案,也是最推荐的方式。
Python
复制
data[feature] = data[feature].fillna(mode_value)

3.可视化分析

4.机器学习模型建模

数据划分


# 划分训练集和测试机
from sklearn.model_selection import train_test_split
X = data.drop(['Credit Default'], axis=1)  # 特征,axis=1表示按列删除
y = data['Credit Default']  # 标签
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)  # 划分数据集,20%作为测试集,随机种子为42
# 训练集和测试集的形状
print(f"训练集形状: {X_train.shape}, 测试集形状: {X_test.shape}")  # 打印训练集和测试集的形状
训练集形状: (6000, 31), 测试集形状: (1500, 31)

模型训练与评估

# #安装xgboost库
# !pip install xgboost -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
# #安装lightgbm库 
# !pip install lightgbm  -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
# #安装catboost库
# !pip install catboost -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Requirement already satisfied: xgboost in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (2.1.4)
Requirement already satisfied: numpy in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from xgboost) (2.0.2)
Requirement already satisfied: scipy in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from xgboost) (1.13.1)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Requirement already satisfied: lightgbm in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (4.6.0)
Requirement already satisfied: numpy>=1.17.0 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from lightgbm) (2.0.2)
Requirement already satisfied: scipy in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from lightgbm) (1.13.1)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: catboost in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (1.2.8)
Requirement already satisfied: graphviz in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (0.20.3)
Requirement already satisfied: matplotlib in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (3.9.2)
Requirement already satisfied: numpy<3.0,>=1.16.0 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (2.0.2)
Requirement already satisfied: pandas>=0.24 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (2.2.3)
Requirement already satisfied: scipy in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (1.13.1)
Requirement already satisfied: plotly in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (6.1.2)
Requirement already satisfied: six in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from catboost) (1.17.0)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from pandas>=0.24->catboost) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from pandas>=0.24->catboost) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from pandas>=0.24->catboost) (2025.2)
Requirement already satisfied: contourpy>=1.0.1 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (1.2.1)
Requirement already satisfied: cycler>=0.10 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (4.55.3)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (1.4.4)
Requirement already satisfied: packaging>=20.0 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (24.2)
Requirement already satisfied: pillow>=8 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (11.1.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (3.2.0)
Requirement already satisfied: importlib-resources>=3.2.0 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from matplotlib->catboost) (6.4.0)
Requirement already satisfied: zipp>=3.1.0 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from importlib-resources>=3.2.0->matplotlib->catboost) (3.21.0)
Requirement already satisfied: narwhals>=1.15.1 in c:\programdata\anaconda3\envs\ml_env\lib\site-packages (from plotly->catboost) (1.41.0)
from sklearn.svm import SVC #支持向量机分类器
from sklearn.neighbors import KNeighborsClassifier #K近邻分类器
from sklearn.linear_model import LogisticRegression #逻辑回归分类器
import xgboost as xgb #XGBoost分类器
import lightgbm as lgb #LightGBM分类器
from sklearn.ensemble import RandomForestClassifier #随机森林分类器
from catboost import CatBoostClassifier #CatBoost分类器
from sklearn.tree import DecisionTreeClassifier #决策树分类器
from sklearn.naive_bayes import GaussianNB #高斯朴素贝叶斯分类器
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标
from sklearn.metrics import classification_report, confusion_matrix #用于生成分类报告和混淆矩阵
import warnings #用于忽略警告信息
warnings.filterwarnings("ignore") # 忽略所有警告信息
# KNN
knn_model = KNeighborsClassifier()
knn_model.fit(X_train, y_train)
knn_pred = knn_model.predict(X_test)print("\nKNN 分类报告:")
print(classification_report(y_test, knn_pred))
print("KNN 混淆矩阵:")
print(confusion_matrix(y_test, knn_pred))knn_accuracy = accuracy_score(y_test, knn_pred)
knn_precision = precision_score(y_test, knn_pred)
knn_recall = recall_score(y_test, knn_pred)
knn_f1 = f1_score(y_test, knn_pred)
print("KNN 模型评估指标:")
print(f"准确率: {knn_accuracy:.4f}")
print(f"精确率: {knn_precision:.4f}")
print(f"召回率: {knn_recall:.4f}")
print(f"F1 值: {knn_f1:.4f}")
KNN 分类报告:precision    recall  f1-score   support0       0.73      0.86      0.79      10591       0.41      0.24      0.30       441accuracy                           0.68      1500macro avg       0.57      0.55      0.54      1500
weighted avg       0.64      0.68      0.65      1500KNN 混淆矩阵:
[[908 151][336 105]]
KNN 模型评估指标:
准确率: 0.6753
精确率: 0.4102
召回率: 0.2381
F1 值: 0.3013
# 逻辑回归
logreg_model = LogisticRegression(random_state=42)
logreg_model.fit(X_train, y_train)
logreg_pred = logreg_model.predict(X_test)print("\n逻辑回归 分类报告:")
print(classification_report(y_test, logreg_pred))
print("逻辑回归 混淆矩阵:")
print(confusion_matrix(y_test, logreg_pred))logreg_accuracy = accuracy_score(y_test, logreg_pred)
logreg_precision = precision_score(y_test, logreg_pred)
logreg_recall = recall_score(y_test, logreg_pred)
logreg_f1 = f1_score(y_test, logreg_pred)
print("逻辑回归 模型评估指标:")
print(f"准确率: {logreg_accuracy:.4f}")
print(f"精确率: {logreg_precision:.4f}")
print(f"召回率: {logreg_recall:.4f}")
print(f"F1 值: {logreg_f1:.4f}")
逻辑回归 分类报告:precision    recall  f1-score   support0       0.75      0.99      0.85      10591       0.86      0.20      0.33       441accuracy                           0.76      1500macro avg       0.80      0.59      0.59      1500
weighted avg       0.78      0.76      0.70      1500逻辑回归 混淆矩阵:
[[1044   15][ 351   90]]
逻辑回归 模型评估指标:
准确率: 0.7560
精确率: 0.8571
召回率: 0.2041
F1 值: 0.3297
# 朴素贝叶斯
nb_model = GaussianNB()
nb_model.fit(X_train, y_train)
nb_pred = nb_model.predict(X_test)print("\n朴素贝叶斯 分类报告:")
print(classification_report(y_test, nb_pred))
print("朴素贝叶斯 混淆矩阵:")
print(confusion_matrix(y_test, nb_pred))nb_accuracy = accuracy_score(y_test, nb_pred)
nb_precision = precision_score(y_test, nb_pred)
nb_recall = recall_score(y_test, nb_pred)
nb_f1 = f1_score(y_test, nb_pred)
print("朴素贝叶斯 模型评估指标:")
print(f"准确率: {nb_accuracy:.4f}")
print(f"精确率: {nb_precision:.4f}")
print(f"召回率: {nb_recall:.4f}")
print(f"F1 值: {nb_f1:.4f}")
朴素贝叶斯 分类报告:precision    recall  f1-score   support0       0.98      0.19      0.32      10591       0.34      0.99      0.50       441accuracy                           0.43      1500macro avg       0.66      0.59      0.41      1500
weighted avg       0.79      0.43      0.38      1500朴素贝叶斯 混淆矩阵:
[[204 855][  5 436]]
朴素贝叶斯 模型评估指标:
准确率: 0.4267
精确率: 0.3377
召回率: 0.9887
F1 值: 0.5035
# 决策树
dt_model = DecisionTreeClassifier(random_state=42)
dt_model.fit(X_train, y_train)
dt_pred = dt_model.predict(X_test)print("\n决策树 分类报告:")
print(classification_report(y_test, dt_pred))
print("决策树 混淆矩阵:")
print(confusion_matrix(y_test, dt_pred))dt_accuracy = accuracy_score(y_test, dt_pred)
dt_precision = precision_score(y_test, dt_pred)
dt_recall = recall_score(y_test, dt_pred)
dt_f1 = f1_score(y_test, dt_pred)
print("决策树 模型评估指标:")
print(f"准确率: {dt_accuracy:.4f}")
print(f"精确率: {dt_precision:.4f}")
print(f"召回率: {dt_recall:.4f}")
print(f"F1 值: {dt_f1:.4f}")
决策树 分类报告:precision    recall  f1-score   support0       0.79      0.75      0.77      10591       0.46      0.51      0.48       441accuracy                           0.68      1500macro avg       0.62      0.63      0.62      1500
weighted avg       0.69      0.68      0.68      1500决策树 混淆矩阵:
[[791 268][216 225]]
决策树 模型评估指标:
准确率: 0.6773
精确率: 0.4564
召回率: 0.5102
F1 值: 0.4818
# 随机森林
rf_model = RandomForestClassifier(random_state=42)
rf_model.fit(X_train, y_train)
rf_pred = rf_model.predict(X_test)print("\n随机森林 分类报告:")
print(classification_report(y_test, rf_pred))
print("随机森林 混淆矩阵:")
print(confusion_matrix(y_test, rf_pred))rf_accuracy = accuracy_score(y_test, rf_pred)
rf_precision = precision_score(y_test, rf_pred)
rf_recall = recall_score(y_test, rf_pred)
rf_f1 = f1_score(y_test, rf_pred)
print("随机森林 模型评估指标:")
print(f"准确率: {rf_accuracy:.4f}")
print(f"精确率: {rf_precision:.4f}")
print(f"召回率: {rf_recall:.4f}")
print(f"F1 值: {rf_f1:.4f}")
随机森林 分类报告:precision    recall  f1-score   support0       0.77      0.97      0.86      10591       0.79      0.30      0.43       441accuracy                           0.77      1500macro avg       0.78      0.63      0.64      1500
weighted avg       0.77      0.77      0.73      1500随机森林 混淆矩阵:
[[1023   36][ 309  132]]
随机森林 模型评估指标:
准确率: 0.7700
精确率: 0.7857
召回率: 0.2993
F1 值: 0.4335
# XGBoost
xgb_model = xgb.XGBClassifier(random_state=42)
xgb_model.fit(X_train, y_train)
xgb_pred = xgb_model.predict(X_test)print("\nXGBoost 分类报告:")
print(classification_report(y_test, xgb_pred))
print("XGBoost 混淆矩阵:")
print(confusion_matrix(y_test, xgb_pred))xgb_accuracy = accuracy_score(y_test, xgb_pred)
xgb_precision = precision_score(y_test, xgb_pred)
xgb_recall = recall_score(y_test, xgb_pred)
xgb_f1 = f1_score(y_test, xgb_pred)
print("XGBoost 模型评估指标:")
print(f"准确率: {xgb_accuracy:.4f}")
print(f"精确率: {xgb_precision:.4f}")
print(f"召回率: {xgb_recall:.4f}")
print(f"F1 值: {xgb_f1:.4f}")
XGBoost 分类报告:precision    recall  f1-score   support0       0.77      0.91      0.84      10591       0.62      0.37      0.46       441accuracy                           0.75      1500macro avg       0.70      0.64      0.65      1500
weighted avg       0.73      0.75      0.72      1500XGBoost 混淆矩阵:
[[960  99][280 161]]
XGBoost 模型评估指标:
准确率: 0.7473
精确率: 0.6192
召回率: 0.3651
F1 值: 0.4593
# LightGBM
lgb_model = lgb.LGBMClassifier(random_state=42)
lgb_model.fit(X_train, y_train)
lgb_pred = lgb_model.predict(X_test)print("\nLightGBM 分类报告:")
print(classification_report(y_test, lgb_pred))
print("LightGBM 混淆矩阵:")
print(confusion_matrix(y_test, lgb_pred))lgb_accuracy = accuracy_score(y_test, lgb_pred)
lgb_precision = precision_score(y_test, lgb_pred)
lgb_recall = recall_score(y_test, lgb_pred)
lgb_f1 = f1_score(y_test, lgb_pred)
print("LightGBM 模型评估指标:")
print(f"准确率: {lgb_accuracy:.4f}")
print(f"精确率: {lgb_precision:.4f}")
print(f"召回率: {lgb_recall:.4f}")
print(f"F1 值: {lgb_f1:.4f}")
[LightGBM] [Warning] Found whitespace in feature_names, replace with underlines
[LightGBM] [Info] Number of positive: 1672, number of negative: 4328
[LightGBM] [Info] Auto-choosing row-wise multi-threading, the overhead of testing was 0.000467 seconds.
You can set `force_row_wise=true` to remove the overhead.
And if memory is not enough, you can set `force_col_wise=true`.
[LightGBM] [Info] Total Bins 2160
[LightGBM] [Info] Number of data points in the train set: 6000, number of used features: 26
[LightGBM] [Info] [binary:BoostFromScore]: pavg=0.278667 -> initscore=-0.951085
[LightGBM] [Info] Start training from score -0.951085LightGBM 分类报告:precision    recall  f1-score   support0       0.78      0.94      0.85      10591       0.70      0.36      0.47       441accuracy                           0.77      1500macro avg       0.74      0.65      0.66      1500
weighted avg       0.75      0.77      0.74      1500LightGBM 混淆矩阵:
[[992  67][284 157]]
LightGBM 模型评估指标:
准确率: 0.7660
精确率: 0.7009
召回率: 0.3560
F1 值: 0.4722

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/web/82035.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于对比学习的推荐系统开发方案,使用Python在PyCharm中实现

以下是一个基于对比学习的推荐系统开发方案,使用Python在PyCharm中实现。本文将详细阐述技术原理、系统设计和完整代码实现。 基于对比学习的推荐系统开发方案 一、技术背景与原理 1.1 对比学习核心思想 对比学习(Contrastive Learning)通过最大化正样本相似度、最小化负…

2025山东CCPC题解

文章目录 L - StellaD - Distributed SystemI - Square PuzzleE - Greatest Common DivisorG - Assembly Line L - Stella 题目来源&#xff1a;L - Stella 解题思路 签到题&#xff0c;因为给出的字母不是按顺序&#xff0c;可以存起来赋其值&#xff0c;然后在比较。 代码…

某航参数逆向及设备指纹分析

文章目录 1. 写在前面2. 接口分析3. 加密分析4. 算法还原5. 设备指纹风控分析与绕过 【&#x1f3e0;作者主页】&#xff1a;吴秋霖 【&#x1f4bc;作者介绍】&#xff1a;擅长爬虫与JS加密逆向分析&#xff01;Python领域优质创作者、CSDN博客专家、阿里云博客专家、华为云享…

Python训练营---Day41

DAY 41 简单CNN 知识回顾 数据增强卷积神经网络定义的写法batch归一化&#xff1a;调整一个批次的分布&#xff0c;常用与图像数据特征图&#xff1a;只有卷积操作输出的才叫特征图调度器&#xff1a;直接修改基础学习率 卷积操作常见流程如下&#xff1a; 1. 输入 → 卷积层 …

【Netty系列】Reactor 模式 2

目录 流程图说明 关键流程 以下是 Reactor 模式流程图&#xff0c;结合 Netty 的主从多线程模型&#xff0c;帮助你直观理解事件驱动和线程分工&#xff1a; 流程图说明 Clients&#xff08;客户端&#xff09; 多个客户端&#xff08;Client 1~N&#xff09;向服务端发起连…

前端开发中 <> 符号解析问题全解:React、Vue 与 UniApp 场景分析与解决方案

前端开发中 <> 符号解析问题全解&#xff1a;React、Vue 与 UniApp 场景分析与解决方案 在前端开发中&#xff0c;<> 符号在 JSX/TSX 环境中常被错误解析为标签而非比较运算符或泛型&#xff0c;导致语法错误和逻辑异常。本文全面解析该问题在不同框架中的表现及解…

【Web应用】 Java + Vue 前后端开发中的Cookie、Token 和 Swagger介绍

文章目录 前言一、Cookie二、Token三、Swagger总结 前言 在现代的 web 开发中&#xff0c;前后端分离的架构越来越受到欢迎&#xff0c;Java 和 Vue 是这一架构中常用的技术栈。在这个过程中&#xff0c;Cookie、Token 和 Swagger 是三个非常重要的概念。本文将对这三个词进行…

投稿Cover Letter怎么写

Cover Letter控制在一页比较好&#xff0c;简短有力地推荐你的文章。 Dear Editors: Small objects detection in remote sensing field remains several challenges, including complex backgrounds, limited pixel representation, and dense object distribution, which c…

创建型设计模式之Prototype(原型)

创建型设计模式之Prototype&#xff08;原型&#xff09; 摘要&#xff1a; Prototype&#xff08;原型&#xff09;设计模式通过复制现有对象来创建新对象&#xff0c;避免重复初始化操作。该模式包含Prototype接口声明克隆方法、ConcretePrototype实现具体克隆逻辑&#xff…

spark在执行中如何选择shuffle策略

目录 1. SortShuffleManager与HashShuffleManager的选择2. Shuffle策略的自动选择机制3. 关键配置参数4. 版本差异(3.0+新特性)5. 异常处理与调优6. 高级Shuffle服务(CSS)1. SortShuffleManager与HashShuffleManager的选择 SortShuffleManager:默认使用,适用于大规模数据…

AUTOSAR图解==>AUTOSAR_EXP_AIADASAndVMC

AUTOSAR高级驾驶辅助系统与车辆运动控制接口详解 基于AUTOSAR R22-11标准的ADAS与VMC接口规范解析 目录 1. 引言2. 术语和概念说明 2.1 坐标系统2.2 定义 2.2.1 乘用车重心2.2.2 极坐标系统2.2.3 车辆加速度/推进力方向2.2.4 倾斜方向2.2.5 方向盘角度2.2.6 道路变量2.2.7 曲率…

26考研——文件管理_文件目录(4)

408答疑 文章目录 二、文件目录1、目录的作用与结构1.1、目录的基本概念1.2、目录的组织形式1.2.1、单级目录结构1.2.2、两级目录结构1.2.3、多级&#xff08;树形&#xff09;目录结构1.2.4、无环图目录结构 1.3、目录的实现方式1.3.1、线性列表1.3.2、哈希表 2、文件共享与链…

Maven 项目中集成数据库文档生成工具

在 Maven 项目中&#xff0c;可以通过集成 数据库文档生成工具&#xff08;如 screw-maven-plugin、mybatis-generator 或 liquibase&#xff09;来自动生成数据库文档。以下是使用 screw-maven-plugin&#xff08;推荐&#xff09;的完整配置步骤&#xff1a; 1. 添加插件配置…

WebSocket指数避让与重连机制

1. 引言 在现代Web应用中&#xff0c;WebSocket技术已成为实现实时通信的重要手段。与传统的HTTP请求-响应模式不同&#xff0c;WebSocket建立持久连接&#xff0c;使服务器能够主动向客户端推送数据&#xff0c;极大地提升了Web应用的实时性和交互体验。然而&#xff0c;在实…

本地部署AI工作流

&#x1f9f0; 主流 RAG / 工作流工具对比表&#xff08;含是否免费、本地部署支持与资源需求&#xff09; 工具名类型是否支持 RAG可视化目标用户是否免费支持本地部署本地部署一般配置Dify企业级问答系统平台✅✅非技术 & 企业用户✅ 免费版 商业版✅ 支持2C4G 起&…

React 第五十节 Router 中useNavigationType的使用详细介绍

前言 useNavigationType 是 React Router v6 提供的一个钩子&#xff0c;用于确定用户如何导航到当前页面。 它提供了关于导航类型的洞察&#xff0c;有助于优化用户体验和实现特定导航行为。 一、useNavigationType 核心用途 1.1、检测导航方式&#xff1a; 判断用户是通过…

4.2.3 Spark SQL 手动指定数据源

在本节实战中&#xff0c;我们学习了如何在Spark SQL中手动指定数据源以及如何使用format()和option()方法。通过案例演示&#xff0c;我们读取了不同格式的数据文件&#xff0c;包括CSV、JSON&#xff0c;并从JDBC数据源读取数据&#xff0c;展示了如何将这些数据转换为DataFr…

【AUTOSAR OS】计数器Counter机制解析:定义、实现与应用

一、Counter的定义与作用 在AUTOSAR Classic Platform&#xff08;CP&#xff09;中&#xff0c;**Counter&#xff08;计数器&#xff09;**是系统实现时间管理的核心组件&#xff0c;用于测量时间间隔、触发报警&#xff08;Alarm&#xff09;和调度表&#xff08;Schedule …

在机器视觉测量和机器视觉定位中,棋盘格标定如何影响精度

棋盘格标定是机器视觉(尤其是基于相机的系统)中进行相机内参(焦距、主点、畸变系数)和外参(相机相对于世界坐标系的位置和姿态)标定的经典且广泛应用的方法。它的质量直接、显著且多方面地影响最终的视觉测量和定位精度。 以下是棋盘格标定如何影响精度的详细分析: 标定…

SOC-ESP32S3部分:21-非易失性存储库

飞书文档https://x509p6c8to.feishu.cn/wiki/QB0Zw7GLeio4l4kyaWQcuQT3nZS 非易失性存储 (NVS) 库主要用于在 flash 中存储键值格式的数据。 它允许我们在芯片的闪存中存储和读取数据&#xff0c;即使在断电后&#xff0c;这些数据也不会丢失。 NVS 是 ESP32 flash&#xff…