西宁做网站公司哪家好wordpress 国际化 mo

张小明 2026/1/10 23:24:08
西宁做网站公司哪家好,wordpress 国际化 mo,如何建立属于自己的网址,何使网站的页面结构更为合理建浙大疏锦行 一、数据准备与基线模型 # 先运行之前预处理好的代码 import pandas as pd import pandas as pd #用于数据处理和分析#xff0c;可处理表格数据。 import numpy as np #用于数值计算#xff0c;提供了高效的数组操作。 import matplotlib.pyplot as plt…浙大疏锦行一、数据准备与基线模型# 先运行之前预处理好的代码 import pandas as pd import pandas as pd #用于数据处理和分析可处理表格数据。 import numpy as np #用于数值计算提供了高效的数组操作。 import matplotlib.pyplot as plt #用于绘制各种类型的图表 import seaborn as sns #基于matplotlib的高级绘图库能绘制更美观的统计图形。 import warnings warnings.filterwarnings(ignore) # 设置中文字体解决中文显示问题 plt.rcParams[font.sans-serif] [SimHei] # Windows系统常用黑体字体 plt.rcParams[axes.unicode_minus] False # 正常显示负号 data pd.read_csv(E:\study\PythonStudy\python60-days-challenge-master\data.csv) #读取数据 # 先筛选字符串变量 discrete_features data.select_dtypes(include[object]).columns.tolist() # 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(E:\study\PythonStudy\python60-days-challenge-master\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}, inplaceTrue) # 重命名列 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, inplaceTrue) #用众数填充该列的缺失值inplaceTrue表示直接在原数据上修改。 # 最开始也说了 很多调参函数自带交叉验证甚至是必选的参数你如果想要不交叉反而实现起来会麻烦很多 # 所以这里我们还是只划分一次数据集 from sklearn.model_selection import train_test_split X data.drop([Credit Default], axis1) # 特征axis1表示按列删除 y data[Credit Default] # 标签 # 按照8:2划分训练集和测试集 X_train, X_test, y_train, y_test train_test_split(X, y, test_size0.2, random_state42) # 80%训练集20%测试集 from sklearn.ensemble import RandomForestClassifier #随机森林分类器 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) # 忽略所有警告信息 # --- 1. 默认参数的随机森林 --- # 评估基准模型这里确实不需要验证集 print(--- 1. 默认参数随机森林 (训练集 - 测试集) ---) rf_model RandomForestClassifier(random_state42) 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))二、数据层面处理方法2.1过采样方法## --- 2. 随机过采样 (Random Oversampling) --- print(\n--- 2. 随机过采样 (Random Oversampling) ---) # 导入随机过采样器 from imblearn.over_sampling import RandomOverSampler import time # 实例化随机过采样器设置 sampling_strategyminority 表示只对少数类进行采样 # random_state 用于确保结果可复现 ros RandomOverSampler(sampling_strategyminority, random_state42) # 对训练集进行过采样。注意只对训练集进行操作测试集保持不变 start_time time.time() X_resampled_ros, y_resampled_ros ros.fit_resample(X_train, y_train) end_time time.time() print(f随机过采样耗时: {end_time - start_time:.4f} 秒) # 检查采样后的类别分布 print(\n随机过采样后训练集类别分布:) print(pd.Series(y_resampled_ros).value_counts()) # 使用过采样后的数据训练随机森林模型 rf_model_ros RandomForestClassifier(random_state42) rf_model_ros.fit(X_resampled_ros, y_resampled_ros) # 在过采样后的训练集上训练 rf_pred_ros rf_model_ros.predict(X_test) # 在原始测试集上预测 print(\n随机过采样后模型 在测试集上的分类报告) print(classification_report(y_test, rf_pred_ros)) print(随机过采样后模型 在测试集上的混淆矩阵) print(confusion_matrix(y_test, rf_pred_ros)) ## --- 3. SMOTE 过采样 (Synthetic Minority Over-sampling Technique) --- print(\n--- 3. SMOTE 过采样 (Synthetic Minority Over-sampling Technique) ---) # 导入 SMOTE 过采样器 from imblearn.over_sampling import SMOTE # 实例化 SMOTE 过采样器 smote SMOTE(random_state42) # 对训练集进行 SMOTE 过采样 start_time time.time() X_resampled_smote, y_resampled_smote smote.fit_resample(X_train, y_train) end_time time.time() print(fSMOTE 过采样耗时: {end_time - start_time:.4f} 秒) # 检查采样后的类别分布 print(\nSMOTE 过采样后训练集类别分布:) print(pd.Series(y_resampled_smote).value_counts()) # 使用 SMOTE 过采样后的数据训练随机森林模型 rf_model_smote RandomForestClassifier(random_state42) rf_model_smote.fit(X_resampled_smote, y_resampled_smote) # 在过采样后的训练集上训练 rf_pred_smote rf_model_smote.predict(X_test) # 在原始测试集上预测 print(\nSMOTE 过采样后模型 在测试集上的分类报告) print(classification_report(y_test, rf_pred_smote)) print(SMOTE 过采样后模型 在测试集上的混淆矩阵) print(confusion_matrix(y_test, rf_pred_smote)) ## --- 6. 欠采样随机欠采样 (Random Under-Sampling) --- print(\n--- 6. 欠采样随机欠采样 (Random Under-Sampling) ---) # 导入随机欠采样器 from imblearn.under_sampling import RandomUnderSampler # 实例化随机欠采样器sampling_strategymajority 表示只对多数类进行采样 rus RandomUnderSampler(sampling_strategymajority, random_state42) # 对训练集进行欠采样 start_time time.time() # X_resampled_rus 和 y_resampled_rus 是欠采样后的训练集 X_resampled_rus, y_resampled_rus rus.fit_resample(X_train, y_train) end_time time.time() print(f随机欠采样耗时: {end_time - start_time:.4f} 秒) # 检查采样后的类别分布 print(\n随机欠采样后训练集类别分布:) # 欠采样后多数类样本数量将等于少数类样本数量 print(pd.Series(y_resampled_rus).value_counts()) # 使用欠采样后的数据训练随机森林模型 rf_model_rus RandomForestClassifier(random_state42) rf_model_rus.fit(X_resampled_rus, y_resampled_rus) rf_pred_rus rf_model_rus.predict(X_test) # 在原始测试集上预测 print(\n随机欠采样后模型 在测试集上的分类报告) print(classification_report(y_test, rf_pred_rus)) print(confusion_matrix(y_test, rf_pred_rus)) ## --- 7. 欠采样Edited Nearest Neighbors (ENN) --- print(\n--- 7. 欠采样Edited Nearest Neighbors (ENN) ---) from imblearn.under_sampling import EditedNearestNeighbours # 实例化 ENN (默认参数通常用于清理多数类样本) # sampling_strategyall 表示对所有类别应用规则但实际主要移除多数类中的噪声 enn EditedNearestNeighbours(sampling_strategyall, n_neighbors3, kind_selall) # 对训练集进行 ENN 欠采样数据清洗 start_time time.time() X_resampled_enn, y_resampled_enn enn.fit_resample(X_train, y_train) end_time time.time() print(fENN 欠采样耗时: {end_time - start_time:.4f} 秒) # 检查采样后的类别分布 print(\nENN 欠采样后训练集类别分布:) # 注意ENN 是数据清洗不会完全平衡数据集多数类样本会减少但仍多于少数类 print(pd.Series(y_resampled_enn).value_counts()) # 使用 ENN 欠采样后的数据训练随机森林模型 rf_model_enn RandomForestClassifier(random_state42) rf_model_enn.fit(X_resampled_enn, y_resampled_enn) rf_pred_enn rf_model_enn.predict(X_test) print(\nENN 欠采样后模型 在测试集上的分类报告) print(classification_report(y_test, rf_pred_enn)) print(confusion_matrix(y_test, rf_pred_enn)) ## --- 8. 混合采样SMOTE ENN (SMOTENN) --- print(\n--- 8. 混合采样SMOTE ENN (SMOTENN) ---) # 导入 SMOTENN from imblearn.combine import SMOTEENN # 实例化 SMOTEENN它内部集成了 SMOTE 和 ENN # random_state 用于确保结果可复现 smote_enn SMOTEENN(random_state42) # 对训练集进行混合采样 start_time time.time() # X_resampled_smotenn 和 y_resampled_smotenn 是混合采样后的训练集 X_resampled_smotenn, y_resampled_smotenn smote_enn.fit_resample(X_train, y_train) end_time time.time() print(fSMOTE ENN 混合采样耗时: {end_time - start_time:.4f} 秒) # 检查采样后的类别分布 print(\nSMOTE ENN 混合采样后训练集类别分布:) # 经过 SMOTE 和 ENN 清理后数据集通常会接近平衡但多数类会略有减少 print(pd.Series(y_resampled_smotenn).value_counts()) # 使用混合采样后的数据训练随机森林模型 rf_model_smotenn RandomForestClassifier(random_state42) rf_model_smotenn.fit(X_resampled_smotenn, y_resampled_smotenn) rf_pred_smotenn rf_model_smotenn.predict(X_test) # 在原始测试集上预测 print(\nSMOTE ENN 混合采样后模型 在测试集上的分类报告) print(classification_report(y_test, rf_pred_smotenn)) print(SMOTE ENN 混合采样后模型 在测试集上的混淆矩阵) print(confusion_matrix(y_test, rf_pred_smotenn))三.算法层面四.评估指标方面
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网站后台上传文章网站设计方式

1. Selenium 4核心新特性解读 1.1 原生相对定位器(Relative Locators) Selenium 4引入了基于视觉关系的“相对定位器”功能,彻底改变了元素定位策略: 1.3 改进的窗口与标签页管理 全新的窗口和标签页API解决了多窗口测试的痛点…

张小明 2026/1/11 4:32:52 网站建设

淄博论坛网站建设上海关键词优化推荐

第一章:从自动化测试困局看识别技术的演进必要性在现代软件交付周期不断压缩的背景下,自动化测试已成为保障质量的核心手段。然而,随着前端技术的快速迭代和UI复杂度的提升,传统基于固定选择器(如ID、XPath&#xff09…

张小明 2026/1/9 22:09:00 网站建设

南通医院网站建设方案响应式网站一般做多大

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 创建一个对比测试项目:1. 传统方式手动编写VGG模型代码 2. 使用快马平台AI生成相同功能的VGG模型 3. 比较两者的开发时间、代码质量和模型准确率 4. 生成详细的对比报告…

张小明 2026/1/9 22:06:57 网站建设

网站建设编程客户说做网站没效果

前阵子刷社交平台时,一条行业分析帖子让我瞬间清醒 —— 全球知名咨询公司麦肯锡曾发布报告预警,到 2030 年,中国 AI 领域的人才缺口规模可能会突破 400 万!这个数字乍一看或许只是个抽象概念,但结合当下行业现状拆解后…

张小明 2026/1/9 22:04:56 网站建设

资讯网站开发的背景昆明几大网站

第一章:Docker 与 Vercel AI SDK 的 API 对接在现代全栈应用开发中,将容器化服务与前沿的 AI 功能集成已成为标准实践。Docker 提供了稳定、可复用的服务运行环境,而 Vercel AI SDK 则让开发者能够快速接入生成式 AI 模型。通过将二者结合&am…

张小明 2026/1/9 22:02:54 网站建设

做网站需要看的书做微景观的网站

💡实话实说:CSDN上做毕设辅导的都是专业技术服务,大家都要生活,这个很正常。我和其他人不同的是,我有自己的项目库存,不需要找别人拿货再加价,所以能给到超低价格。摘要 近年来,全球…

张小明 2026/1/9 22:00:51 网站建设