自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(44)
  • 资源 (1)
  • 收藏
  • 关注

原创 python打卡DAY44

arrange排列函数。# filter数据筛选。# select选择函数。# mutate变形函数。# join数据合并。

2025-06-10 16:03:26 213

原创 python打卡DAY43

arrange排列函数。# filter数据筛选。# select选择函数。# mutate变形函数。# join数据合并。

2025-06-09 20:06:04 277

原创 python打卡DAY42

# arrange排列函数。# filter数据筛选。# select选择函数。# mutate变形函数。# join数据合并。

2025-06-08 22:42:20 650

原创 python打卡DAY41

dim(t2)# View(t2)# dim(t3)# View(t3)# dim(t6)# View(t6)# dim(t7)# str(tt)# str(tt)# View(tt)attach(tt)# View(tt)detach(tt)attach(tt)})str(tt)

2025-06-07 22:44:06 522

原创 python打卡DAY40

=================== 构建 Attention 模型 =====================print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# =================== 可视化损失与权重 =====================在第{epoch+1}轮,测试集损失已有{patience}轮未改善。# =================== 数据预处理 =====================

2025-06-07 00:31:34 706

原创 python打卡DAY39

=================== 构建 Attention 模型 =====================print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# =================== 可视化损失与权重 =====================在第{epoch+1}轮,测试集损失已有{patience}轮未改善。# =================== 数据预处理 =====================

2025-06-03 20:40:49 675

原创 python打卡DAY38

=================== 构建 Attention 模型 =====================print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# =================== 可视化损失与权重 =====================在第{epoch+1}轮,测试集损失已有{patience}轮未改善。# =================== 数据预处理 =====================

2025-06-02 21:43:09 753

原创 python打卡DAY37

=================== 构建 Attention 模型 =====================# # =================== 可视化损失与权重 =====================# =================== 特征列聚类增强 =====================# =================== 数据预处理 =====================print(f"加载第{best_epoch}轮的最佳模型进行最终评估...")

2025-06-02 08:53:44 923

原创 python打卡DAY36

print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# # =================== 可视化损失与权重 =====================# =================== 特征列聚类增强 =====================# =================== 数据预处理 =====================print(f"加载第{best_epoch}轮的最佳模型进行最终评估...")

2025-05-31 15:28:56 643

原创 python DAY35

=================== 构建 Attention 模型 =====================print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# =================== 可视化损失与权重 =====================# =================== 数据预处理 =====================# # 张量具有to(device)方法,可以将张量移动到指定的设备上。

2025-05-30 20:03:44 588

原创 python打卡DAY34

=================== 构建 Attention 模型 =====================print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# # =================== 可视化损失与权重 =====================print(f"早停触发!# =================== 数据预处理 =====================

2025-05-29 17:28:34 894

原创 python打卡DAY33

=================== 构建 Attention 模型 =====================print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")# =================== 可视化损失与权重 =====================# =================== 数据预处理 =====================# # 张量具有to(device)方法,可以将张量移动到指定的设备上。

2025-05-28 16:31:24 621

原创 python打卡DAY32

ordinal_categories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")print(f"早停触发!

2025-05-27 22:27:27 544

原创 python打卡DAY31

ordinal_categories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)print(f"最佳测试集损失出现在第{best_epoch}轮,损失值为{best_test_loss:.4f}")print(f"早停触发!

2025-05-27 00:43:07 861

原创 python打卡DAY30

# y_train和y_test是整数,所以需要转化为long类型,如果是float32,会输出1.0 0.0。# # 将数据转换为 PyTorch 张量,因为 PyTorch 使用张量进行训练。# # # 归一化数据,神经网络对于输入数据的尺寸敏感,归一化是最常见的处理方式。# # 归一化数据,神经网络对于输入数据的尺寸敏感,归一化是最常见的处理方式。# # ##自变量有多个,且量纲不尽相同对其进行归一化减少量纲对结果的影响。# # 张量具有to(device)方法,可以将张量移动到指定的设备上。

2025-05-25 16:26:22 315

原创 python打卡DAY29

ordinal_categories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# print(f"训练集 t-SNE耗时: {end_time - start_time:.2f} 秒")

2025-05-24 21:47:57 567

原创 python打卡DAY28

ordinal_catagories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# print(f"训练集 t-SNE耗时: {end_time - start_time:.2f} 秒")

2025-05-24 00:41:57 909

原创 python 打卡DAY27

ordinal_catagories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# # from sklearn.linear_model import LogisticRegression #逻辑回归分类器。

2025-05-23 00:00:13 1110 2

原创 python打卡DAY26

ordinal_catagories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# kmeans_label=kmeans.fit_predict(x_scaled)#提供了每个数据点所属的簇的信息,用于区分不同簇的数据点。

2025-05-21 22:40:06 734

原创 python打卡DAY25

ordinal_categories = [['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# # from sklearn.linear_model import LogisticRegression #逻辑回归分类器。

2025-05-20 23:51:36 758

原创 python打卡DAY24

ordinal_categories = [['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# kmeans_label=kmeans.fit_predict(x_scaled)#提供了每个数据点所属的簇的信息,用于区分不同簇的数据点。

2025-05-19 22:33:15 340

原创 python打卡DAY23

ordinal_categories=[['< 1 year', '1 year', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '10+ years']] # Years in current job 的顺序 (对应1-11)# kmeans_label=kmeans.fit_predict(x_scaled)#提供了每个数据点所属的簇的信息,用于区分不同簇的数据点。

2025-05-18 19:45:22 870

原创 python打卡DAY22

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。# # print(f'k={k}\n 惯性:{kmeans.inertia_:.2f}\n轮廓系数:{silhouette:.3f}\n CH系数:{ch:.2f}\n DB{db:.3f}')# print(f'聚类分析耗时:{end_time-start_time:.4f}')

2025-05-17 23:48:08 1105

原创 python打卡DAY21

print('shap_values[0,:,:]shape',shap_values[0,:,:].shape)##这里也可以省略后面的写作shap_values[0】,代表第一个样本所有特征对所有类别的贡献,后面部位可以省略但是前面不能。# print(f'k={k}\n 惯性:{kmeans.inertia_:.2f}\n轮廓系数:{silhouette:.3f}\n CH系数:{ch:.2f}\n DB{db:.3f}')

2025-05-17 00:48:52 473

原创 python打卡DAY20

##注入所需库import pandas as pdimport seaborn as snsimport matplotlib.pyplot as pltimport randomimport numpy as npimport timeimport shapfrom sklearn.svm import SVC #支持向量机分类器# from sklearn.neighbors import KNeighborsClassifier #K近邻分类器# from sklearn.linear_model

2025-05-16 00:24:36 914

原创 python打卡DAY19

print('shap_values[0,:,:]shape:',shap_values[0,:,:].shape)##这里也可以省略后面的写作shap_values[0】,代表第一个样本所有特征对所有类别的贡献,后面部位可以省略但是前面不能。# print(f'k={k}\n 惯性:{kmeans.inertia_:.2f}\n轮廓系数:{silhouette:.3f}\n CH系数:{ch:.2f}\n DB{db:.3f}')

2025-05-14 21:29:55 895

原创 python打卡DAY18

print('shap_values[0,:,:] shape:',shap_values[0,:,:].shape)##这里也可以省略后面的写作shap_values[0】,代表第一个样本所有特征对所有类别的贡献,后面部位可以省略但是前面不能。# print(f'k={k}\n 惯性:{kmeans.inertia_:.2f}\n轮廓系数:{silhouette:.3f}\n CH系数:{ch:.2f}\n DB{db:.3f}')

2025-05-14 00:25:23 697

原创 python打卡DAY17

print('shap_values[0,:,:] shape:',shap_values[0,:,:].shape)##这里也可以省略后面的写作shap_values[0】,代表第一个样本所有特征对所有类别的贡献,后面部位可以省略但是前面不能。# print(f'k={k}\n 惯性:{kmeans.inertia_:.2f}\n轮廓系数:{silhouette:.3f}\n CH系数:{ch:.2f}\n DB{db:.3f}')

2025-05-12 23:58:34 801

原创 python打卡DAY16

print('shap_values[0,:,:] shape:',shap_values[0,:,:].shape)####这里也可以省略后面的写作shap_values[0】,后面部位可以省略但是前面不能。#print(f'k={k}\n 惯性:{kmeans.inertia_:.2f}\n 轮廓系数:{silhouette:.3f}\n CH指数:{ch:.2f}\n DB指数{db:.3f}')# print(f'训练与预测耗时:{end_time - start_time:.4f}')

2025-05-12 00:53:22 665

原创 python打卡DAY5

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。# print(f'训练与预测耗时:{end_time - start_time:.4f}')# print(f'训练与预测耗时:{end_time-start_time:.4f}')# print(f'网格搜索耗时:{end_time-start_time:.4f}秒')

2025-05-11 00:10:39 304

原创 python打卡DAY14

n_estimators, max_depth, min_samples_split, min_samples_leaf = params # 序列解包,允许你将一个可迭代对象(如列表、元组、字符串等)中的元素依次赋值给多个变量。from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。

2025-05-10 02:10:10 655

原创 python打卡DAY13

n_estimators, max_depth, min_samples_split, min_samples_leaf = params # 序列解包,允许你将一个可迭代对象(如列表、元组、字符串等)中的元素依次赋值给多个变量。from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。

2025-05-09 00:21:50 473

原创 python打卡DAY12

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。print(f'平均{clean_metric_name}:{np.mean(scores):.4f}(+/-{np.std(scores):.4f})')# print(f"随机过采样后训练与预测耗时: {end_time_ros - start_time_ros:.4f} 秒")

2025-05-08 00:38:01 730

原创 python打卡DAY11

n_estimators, max_depth, min_samples_split, min_samples_leaf = params # 序列解包,允许你将一个可迭代对象(如列表、元组、字符串等)中的元素依次赋值给多个变量。from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。

2025-05-07 00:45:36 678

原创 python打卡DAY10

print(f"遗传算法优化耗时: {end_time - start_time:.4f} 秒")# print(f'训练与预测耗时:{end_time - start_time:.4f}')# print(f'训练与预测耗时:{end_time - start_time:.4f}')# print("\n--- 2. 网格搜索优化随机森林 (训练集 -> 测试集) ---")# print("\n--- 2. 遗传算法优化随机森林 (训练集 -> 测试集) ---")

2025-05-05 20:52:06 719

原创 python打卡DAY9

print("\n--- 2. 网格搜索优化随机森林 (训练集 -> 测试集) ---")# print("--- 1. 默认参数随机森林 (训练集 -> 测试集) ---")# print("--- 1. 默认参数随机森林 (训练集 -> 测试集) ---")# print("--- 1. 默认参数随机森林 (训练集 -> 测试集) ---")# print("--- 1. 默认参数随机森林 (训练集 -> 测试集) ---")

2025-05-05 00:55:24 616

原创 python打卡DAY8

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标。print(f'准确率:{svm_accuracy:.4f}\n精确率:{svm_precision}\n召回率:{svm_recall:.4f}\nF1值:{svm_f1:.4f}')# plt.legend(labels=['否','是'])# plt.xticks([0,1],['否','是'])

2025-05-03 22:00:27 440

原创 python打卡DAY7

print(f'索引{i}对应的特征是:{feature}')# plt.legend(labels=['否','是'])# plt.legend(labels=['否','是'])# plt.legend(labels=['否','是'])# plt.xticks([0,1],['否','是'])# plt.title('年收入箱线图')# plt.title('相关热力图')# plt.xlabel('年收入')#查看基本信息与缺失值。# #绘制热力图&子图。

2025-05-02 21:38:14 524

原创 python打卡DAY6

解释:这里 x='Number of Open Account' 表示 data 这个 DataFrame 中的一列。data=data 明确告诉 seaborn 去这个 DataFrame 中找列。seaborn 内部会根据 x 和 hue 的列名在 data 中自动查找和处理。plt.title('在当前工作年限直方图')plt.xlabel('在当前工作年限')plt.title('年收入箱线图')plt.ylabel('员工数量')plt.xlabel('年收入')

2025-05-02 00:42:07 379

原创 python打卡DAY5

它的核心思想是将数据分成若干个区间(称为“桶”或“bin”),然后统计每个区间内的数据点数量。plt.title('Annual Income 的箱线图')plt.title('在当前工作年限直方图')plt.title('在当前工作年限直方图')plt.xlabel('在当前工作年限')plt.xlabel('在当前工作年限')plt.title('年收入箱线图')plt.ylabel('员工数量')plt.ylabel('员工数量')plt.xlabel('年收入')复习:数据编码与缺失值填补。

2025-04-30 23:18:55 745

python打卡DAY36

python打卡DAY36

2025-05-31

python打卡DAY34

python打卡DAY34

2025-05-29

python打卡DAY38

python打卡DAY38

2025-06-02

python DAY35

python DAY35

2025-05-30

python打卡DAY33

python打卡DAY33

2025-05-28

python打卡DAY32

python打卡DAY32

2025-05-27

python打卡DAY31

python打卡DAY31

2025-05-27

python打卡DAY30

python打卡DAY30

2025-05-25

python打卡DAY29

python打卡DAY29

2025-05-24

python打卡DAY28

python打卡DAY28

2025-05-24

python 打卡DAY27

python 打卡DAY27

2025-05-23

python打卡DAY26

python打卡DAY26

2025-05-21

python打卡DAY25

python打卡DAY25

2025-05-20

python打卡DAY24

python打卡DAY24

2025-05-19

python打卡DAY23

python打卡DAY23

2025-05-18

python打卡DAY22

python打卡DAY22

2025-05-17

python打卡DAY21

python打卡DAY21

2025-05-17

python打卡DAY20

python打卡DAY20

2025-05-16

python打卡DAY19

python打卡DAY19

2025-05-14

python打卡DAY18

python打卡DAY18

2025-05-14

python打卡DAY17

python打卡DAY17

2025-05-12

python打卡DAY16

python打卡DAY16

2025-05-12

python打卡DAY5

python打卡DAY5

2025-05-11

python打卡DAY5

python打卡DAY5

2025-05-11

python打卡DAY14

python打卡DAY14

2025-05-10

python打卡DAY3

python打卡DAY3

2025-05-09

python打卡DAY12

python打卡DAY12

2025-05-08

python打卡DAY11

python打卡DAY11

2025-05-07

python打卡DAY10

python打卡DAY10

2025-05-05

python打卡DAY9

python打卡DAY9

2025-05-05

python打卡DAY8

python打卡DAY8

2025-05-03

python打卡DAY7

python打卡DAY7

2025-05-02

python打卡DAY6

python打卡DAY6

2025-05-02

python打卡DAY5

python打卡DAY5

2025-04-30

python打卡DAY4

python打卡DAY4

2025-04-29

python打卡DAY3

python打卡DAY3

2025-04-28

python打卡DAY2

python打卡DAY2

2025-04-27

python打卡day1

打卡训练

2025-04-26

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除