当前位置: 首页 > news >正文

ajax做网站苏州吴江太湖新城建设局网站

ajax做网站,苏州吴江太湖新城建设局网站,wordpress page.php,哪些网站专门做康复科#x1f368; 本文为#x1f517;365天深度学习训练营 中的学习记录博客#x1f356; 原作者#xff1a;K同学啊 SVM与集成学习 SVMSVM线性模型SVM非线性模型SVM常用参数 集成学习随机森林导入数据查看数据信息数据分析随机森林模型预测结果结果分析 个人总结 SVM 超平面 本文为365天深度学习训练营 中的学习记录博客 原作者K同学啊 SVM与集成学习 SVMSVM线性模型SVM非线性模型SVM常用参数 集成学习随机森林导入数据查看数据信息数据分析随机森林模型预测结果结果分析 个人总结 SVM 超平面SVM 在特征空间中寻找一个能够最大化类别间隔的超平面称为最大间隔超平面。这个超平面就是将数据集分成不同类别的边界。支持向量支持向量是离分隔超平面最近的样本点它们决定了超平面的位置和方向。换句话说只有这些样本对分类结果有影响其他的样本点则不影响。 SVM线性模型 from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC from sklearn.metrics import accuracy_score# 加载数据集 iris datasets.load_iris() X iris.data y iris.target# 数据预处理 sc StandardScaler() X sc.fit_transform(X)# 训练集和测试集的分割 X_train, X_test, y_train, y_test train_test_split(X, y, test_size0.3, random_state42)# 创建SVM模型 svm SVC(kernellinear, C1.0)# 训练模型 svm.fit(X_train, y_train)# 预测 y_pred svm.predict(X_test)# 评估模型性能 accuracy accuracy_score(y_test, y_pred) print(Accuracy: %.2f % (accuracy * 100.0))SVM非线性模型 from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC from sklearn.metrics import accuracy_score# 加载数据集 iris datasets.load_iris() X iris.data y iris.target# 数据预处理 sc StandardScaler() X sc.fit_transform(X)# 训练集和测试集的分割 X_train, X_test, y_train, y_test train_test_split(X, y, test_size0.3, random_state42)# 创建SVM模型 svm SVC(kernelrbf, C1.0, gamma0.1)# 训练模型 svm.fit(X_train, y_train)# 预测 y_pred svm.predict(X_test)# 评估模型性能 accuracy accuracy_score(y_test, y_pred) print(Accuracy: %.2f % (accuracy * 100.0))SVM常用参数 C默认值1.0 ○ 作用惩罚参数用于平衡最大化分类间隔和误分类惩罚之间的关系。 ○ 解释较大的 C 值意味着对误分类的惩罚更大模型会倾向于将更多的训练数据点分类正确但可能会导致间隔变小可能出现过拟合较小的 C 值则会更关注于间隔的大小而允许更多的误分类从而提高模型的泛化能力。 ○ 常用范围通常在 0.001 到 1000 之间进行调节。kernel默认值‘rbf’ ○ 作用指定要使用的核函数支持不同的非线性映射方法。 ○ 可选值 ■ ‘linear’线性核函数即不进行任何非线性映射。 ■ ‘poly’多项式核函数通常用于多项式可分的情况。 ■ ‘rbf’径向基函数Radial Basis Function又称高斯核是最常用的非线性核函数。 ■ ‘sigmoid’类似于神经网络的激活函数较少使用。 ■ 你也可以传递自定义核函数方法是传递一个函数。degree 默认值3 ○ 作用当 kernel‘poly’ 时指定多项式核的多项式次数。 ○ 解释如果使用多项式核函数polydegree 参数决定多项式的阶数通常是 2 或 3。gamma默认值‘scale’ ○ 作用核函数系数适用于 ‘rbf’、‘poly’ 和 ‘sigmoid’ 核函数。 ○ 可选值 ■ ‘scale’使用 1 / (n_features * X.var()) 作为默认值。这个值会根据输入特征的数量和方差自动调整。 ■ ‘auto’使用 1 / n_features 作为值。 ○ 解释gamma 值越大模型越倾向于拟合训练数据但可能会导致过拟合gamma 值越小模型更倾向于平滑。coef0默认值0.0 ○ 作用核函数中的独立项仅在 kernel‘poly’ 或 kernel‘sigmoid’ 时有意义。 ○ 解释用于控制多项式核函数和 sigmoid 核函数中的偏移量。 集成学习 Bagging在做预测时对于分类任务使用简单的投票法。对于回归任务使用简单平均法。若分类预测时出现两个类票数一样时则随机选择一个。Boosting 工作原理 弱学习器中的弱学习器通常是性能稍微优于随机猜测的模型通常使用简单的模型如浅层决策树。加权训练在每一次迭代中Boosting 会调整每个样本的权重增加那些前一次模型预测错误样本的权重使得后续的学习器更关注这些难以分类的样本。加权投票最终模型是通过将所有弱学习器的预测结果加权整合而成通常采用加权投票分类问题或加权平均回归问题。 随机森林 一种基于集成学习的算法主要用于分类和回归分析。随机森林通过结合多个决策树来提高模型的准确性和稳健性步骤如下 随机抽样从原始训练数据中随机抽取多个样本集通常是相同大小为每棵决策树准备训练数据。构建决策树对于每个样本集根据随机选取的特征构建一棵决策树。树的生长过程中使用信息增益、基尼指数等标准进行节点分裂。集成预测 对于分类任务随机森林通过对所有决策树的预测进行投票选择票数最多的类别作为最终类别。 对于回归任务计算所有树的预测值的平均值。 导入数据 import pandas as pd import numpy as np import seaborn as sns from sklearn.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import classification_reportdata pd.read_csv(rC:\Users\11054\Desktop\kLearning\L678_learning\data.csv) data查看数据信息 data.info()import matplotlib.pyplot as pltplt.rcParams[font.family] SimHei # 指定默认字体为黑体 feature_map {Temperature: 温度,Humidity: 湿度百分比,Wind Speed: 风速,Precipitation (%): 降水量百分比,Atmospheric Pressure: 大气压力,UV Index: 紫外线指数,Visibility (km): 能见度 } plt.figure(figsize(15, 10))for i, (col, col_name) in enumerate(feature_map.items(), 1):plt.subplot(2, 4, i)sns.boxplot(ydata[col])plt.title(f{col_name}的箱线图, fontsize14)plt.ylabel(数值, fontsize12)plt.grid(axisy, linestyle--, alpha0.7)plt.tight_layout() plt.show()C:\Users\11054\AppData\Local\Temp\ipykernel_7496\1699620420.py:22: UserWarning: Glyph 8722 (\N{MINUS SIGN}) missing from current font.plt.tight_layout() C:\Users\11054\.conda\envs\kmate\lib\site-packages\IPython\core\pylabtools.py:152: UserWarning: Glyph 8722 (\N{MINUS SIGN}) missing from current font.fig.canvas.print_figure(bytes_io, **kw)print(f温度超过60°C的数据量{data[data[Temperature] 60].shape[0]}占比{round(data[data[Temperature] 60].shape[0] / data.shape[0] * 100,2)}%。) print(f湿度百分比超过100%的数据量{data[data[Humidity] 100].shape[0]}占比{round(data[data[Humidity] 100].shape[0] / data.shape[0] * 100,2)}%。) print(f降雨量百分比超过100%的数据量{data[data[Precipitation (%)] 100].shape[0]}占比{round(data[data[Precipitation (%)] 100].shape[0] / data.shape[0] * 100,2)}%。)温度超过60°C的数据量207占比1.57%。 湿度百分比超过100%的数据量416占比3.15%。 降雨量百分比超过100%的数据量392占比2.97%。数据分析 data.describe(includeall)plt.figure(figsize(20, 15)) plt.subplot(3, 4, 1) sns.histplot(data[Temperature], kdeTrue,bins20) plt.title(温度分布) plt.xlabel(温度) plt.ylabel(频数)plt.subplot(3, 4, 2) sns.boxplot(ydata[Humidity]) plt.title(湿度百分比箱线图) plt.ylabel(湿度百分比)plt.subplot(3, 4, 3) sns.histplot(data[Wind Speed], kdeTrue,bins20) plt.title(风速分布) plt.xlabel(风速km/h) plt.ylabel(频数)plt.subplot(3, 4, 4) sns.boxplot(ydata[Precipitation (%)]) plt.title(降雨量百分比箱线图) plt.ylabel(降雨量百分比)plt.subplot(3, 4, 5) sns.countplot(xCloud Cover, datadata) plt.title(云量 (描述)分布) plt.xlabel(云量 (描述)) plt.ylabel(频数)plt.subplot(3, 4, 6) sns.histplot(data[Atmospheric Pressure], kdeTrue,bins10) plt.title(大气压分布) plt.xlabel(气压 (hPa)) plt.ylabel(频数)plt.subplot(3, 4, 7) sns.histplot(data[UV Index], kdeTrue,bins14) plt.title(紫外线等级分布) plt.xlabel(紫外线指数) plt.ylabel(频数)plt.subplot(3, 4, 8) Season_counts data[Season].value_counts() plt.pie(Season_counts, labelsSeason_counts.index, autopct%1.1f%%, startangle140) plt.title(季节分布)plt.subplot(3, 4, 9) sns.histplot(data[Visibility (km)], kdeTrue,bins10) plt.title(能见度分布) plt.xlabel(能见度Km) plt.ylabel(频数)plt.subplot(3, 4, 10) sns.countplot(xLocation, datadata) plt.title(地点分布) plt.xlabel(地点) plt.ylabel(频数)plt.subplot(3, 4, (11,12)) sns.countplot(xWeather Type, datadata) plt.title(天气类型分布) plt.xlabel(天气类型) plt.ylabel(频数)plt.tight_layout() plt.show()C:\Users\11054\AppData\Local\Temp\ipykernel_7496\3587563545.py:65: UserWarning: Glyph 8722 (\N{MINUS SIGN}) missing from current font.plt.tight_layout() C:\Users\11054\.conda\envs\kmate\lib\site-packages\IPython\core\pylabtools.py:152: UserWarning: Glyph 8722 (\N{MINUS SIGN}) missing from current font.fig.canvas.print_figure(bytes_io, **kw)随机森林模型 new_data data.copy() label_encoders {} categorical_features [Cloud Cover, Season, Location, Weather Type] for feature in categorical_features:le LabelEncoder()new_data[feature] le.fit_transform(data[feature])label_encoders[feature] lefor feature in categorical_features:print(f{feature}特征的对应关系)for index, class_ in enumerate(label_encoders[feature].classes_):print(f {index}: {class_}) Cloud Cover特征的对应关系0: clear1: cloudy2: overcast3: partly cloudy Season特征的对应关系0: Autumn1: Spring2: Summer3: Winter Location特征的对应关系0: coastal1: inland2: mountain Weather Type特征的对应关系0: Cloudy1: Rainy2: Snowy3: Sunny# 构建xy x new_data.drop([Weather Type],axis1) y new_data[Weather Type]# 划分数据集 x_train,x_test,y_train,y_test train_test_split(x,y,test_size0.3,random_state15)# 构建随机森林模型 rf_clf RandomForestClassifier(random_state15) rf_clf.fit(x_train, y_train)预测结果 y_pred_rf rf_clf.predict(x_test) class_report_rf classification_report(y_test, y_pred_rf) print(class_report_rf)precision recall f1-score support0 0.87 0.93 0.90 10181 0.93 0.91 0.92 9672 0.96 0.92 0.94 10073 0.91 0.91 0.91 968accuracy 0.92 3960macro avg 0.92 0.91 0.92 3960 weighted avg 0.92 0.92 0.92 3960结果分析 feature_importances rf_clf.feature_importances_ features_rf pd.DataFrame({特征: x.columns, 重要度: feature_importances}) features_rf.sort_values(by重要度, ascendingFalse, inplaceTrue) plt.figure(figsize(10, 8)) sns.barplot(x重要度, y特征, datafeatures_rf) plt.xlabel(重要度) plt.ylabel(特征) plt.title(随机森林特征图) plt.show()个人总结 学习了随机森林模型的使用理解了SVM和集成学习的基本原理
http://www.w-s-a.com/news/562403/

相关文章:

  • 开发商城网站多少钱城厢区建设局网站
  • 网站外链多的危害天水市建设局网站
  • 网站接入商学交互设计网站
  • 目前最新的网站后台架构技术综述什么网站可以做名片
  • 成都建站长沙做网站美工的公司
  • 湖南省住房与城乡建设厅网站平顶山网站关键词优化
  • 购物网站前台功能模块汕头网站设计电话
  • 网站你懂我意思正能量免费wordpress菜单底部导航代码
  • 一个主机可以建设多少个网站山东高端网站建设
  • 长沙网站建设搭建网络营销做得好的公司
  • 如何做网站的后台管理石家庄seo关键词排名
  • 给自己公司做个网站山东做外贸网站的公司
  • 张家港网站建设培训江苏省建设工程网站系统
  • html个人网站桂林建站
  • 湛江网站优化快速排名wordpress文章页面宽度
  • 自己建网站怎么弄唯品会一家专门做特卖的网站
  • 做文化传播公司网站做搜狗pc网站点
  • 免费的黄冈网站有哪些平台可以聊天呢要查询一个网站在什么公司做的推广怎么查
  • 凡客建站登录入口网站建设先进部门评选标准
  • 响应式设计 手机网站政务中心建设网站
  • 如何做卖衣服的网站网站登录接口怎么做
  • 网站源码下载了属于侵权吗499全包网站建设
  • 怎样创建网站信息平台网络推广官网首页
  • 网站建设的课程网站 逻辑结构
  • 开通企业网站搬瓦工暗转wordpress
  • 成都网站建设有名的公司怎么做出有品牌感的网站
  • 中国网站的建设淘宝数据网站开发
  • 深圳建站网站模板wordpress 文章最长
  • 服务器建立网站建网站做seo
  • 帮人做彩票网站支付接口网上请人做软件的网站