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

可以做推广东西的网站深圳全网推广效果如何

可以做推广东西的网站,深圳全网推广效果如何,导购网站怎么做,新浪微博 ssc网站建设大侠幸会幸会&#xff0c;我是日更万日 算法金&#xff1b;0 基础跨行转算法&#xff0c;国内外多个算法比赛 Top&#xff1b;放弃 BAT Offer&#xff0c;成功上岸 AI 研究院 Leader&#xff1b; <随机森林及其应用领域> 随机森林是一种强大的机器学习算法&#xff0c;其…

大侠幸会幸会,我是日更万日 算法金;0 基础跨行转算法,国内外多个算法比赛 Top;放弃 BAT Offer,成功上岸 AI 研究院 Leader;

<随机森林及其应用领域> 随机森林是一种强大的机器学习算法,其基本原理在于通过集成多个决策树来提高整体性能。决策树是一种流程图结构,通过一系列的决策来达到最终目标。

而随机森林则是通过构建许多这样的决策树,每个决策树都在某种程度上是独立的,从而提高了模型的稳健性和准确性。这种算法在各种领域都有着广泛的应用。

防失联,进免费知识星球交流。算法知识直达星球:https://t.zsxq.com/ckSu3

  • 项目实战 -
    在接下来的部分,我们深入地探讨特征重要性在实际问题中的运用。我们将使用UCI红酒分类数据集,这个数据集来自UCI机器学习仓库,总共包含了3种红酒,178个样本。每个样本有13个特征,用于描述红酒的各种化学成分。https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data

<加载UCI红酒分类数据集>
数据集概览

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

加载数据集

url = “https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data”
column_names = [“Class”, “Alcohol”, “Malic acid”, “Ash”, “Alcalinity of ash”, “Magnesium”, “Total phenols”, “Flavanoids”, “Nonflavanoid phenols”, “Proanthocyanins”, “Color intensity”, “Hue”, “OD280/OD315 of diluted wines”, “Proline”]
data = pd.read_csv(‘wine-1.csv’, names=column_names)

分割数据集

X = data.drop(“Class”, axis=1)
y = data[“Class”]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

在这段代码的帮助下,我们不需要任何高超的技术,只需要几行简单的代码,就能将这些数据划分成可以训练机器学习模型的形式。

<训练随机森林模型>
构建随机森林模型

创建随机森林分类器

rf_classifier = RandomForestClassifier(n_estimators=100, random_state=42)

在训练集上训练模型

rf_classifier.fit(X_train, y_train)

训练完成后,评估模型

training_accuracy = rf_classifier.score(X_train, y_train)
print(f’训练集准确率:{training_accuracy:.2f}') # 评估训练集上的准确率

test_accuracy = rf_classifier.score(X_test, y_test)
print(f’测试集准确率:{test_accuracy:.2f}') # 评估测试集上的准确率

训练集准确率:1.00测试集准确率:1.0完美!

<查看特征重要性>
特征重要性的计算

决策树是通过计算每次特征划分导致的样本杂质(信息熵等)减少程度,来决定该特征的重要性。RandomForestClassifier会自动计算并存储特征重要性。

获取特征重要性

feature_importance = pd.DataFrame({“Feature”: X_train.columns, “Importance”: rf_classifier.feature_importances_})
feature_importance = feature_importance.sort_values(by=“Importance”, ascending=False)

打印特征重要性

print(feature_importance)

<可视化特征重要性>
import numpy as np
import matplotlib.pyplot as plt

提取特征重要性信息

feature_names = X_train.columns
importances = rf_classifier.feature_importances_
indices = np.argsort(importances)[::-1]

绘制条形图

plt.bar(range(X_train.shape[1]), importances[indices], align=‘center’)

在每个条形图上显示特征重要性数值

for x in range(X_train.shape[1]):
text = ‘{:.2f}’.format(importances[indices[x]])
plt.text(x, importances[indices[x]] + 0.01, text, ha=‘center’)

设置x轴刻度标签

plt.xticks(range(X_train.shape[1]), feature_names[indices], rotation=90)
plt.xlim([-1, X_train.shape[1]])
plt.ylim(0.0, np.max(importances) + 0.05)

添加标签和标题

plt.xlabel(‘Feature’)
plt.ylabel(‘Importance’)
plt.title(‘Random Forest Feature Importance’)

自动调整布局并显示图形

plt.tight_layout()
plt.show()

<自动选择重要特征>
应用特征选择算法

from sklearn.feature_selection import SelectFromModel

使用SelectFromModel进行特征选择

sfm = SelectFromModel(rf_classifier, threshold=‘median’) # 阈值可选,比如threshold=0.1
sfm.fit(X_train, y_train)

选出5个重要特征

X_train_selected = sfm.transform(X_train)
X_test_selected = sfm.transform(X_test)

查看选中的特征

selected_features = X_train.columns[sfm.get_support()]

重新建立模型并在选中特征上进行训练

rf_classifier_selected = RandomForestClassifier(n_estimators=100, random_state=42)
rf_classifier_selected.fit(X_train_selected, y_train)

在测试集上进行预测

y_pred_selected = rf_classifier_selected.predict(X_test_selected)

评估模型性能

accuracy_selected = accuracy_score(y_test, y_pred_selected)

打印选中的特征和模型评估结果

print(“Selected Features:”, list(selected_features))
print(“Model Accuracy with Selected Features:”, accuracy_selected)

自动选择了 7 个重要特征,其中脯氨酸和酒精含量位列前两。这与手动分析特征重要性的结果是一致的。通过运行可以发现,结果和13个特征的方法相当,Cool…


/ __ \ | |
| / / ___ ___ | |
| | / _ \ / _ | |
| _/\ () | () | |
_
/_/ ___/|_|

打完收工 [ 抱拳礼 ]星辰大海,江湖再会,溜了溜了~


文章转载自:
http://dinncorevivalism.bpmz.cn
http://dinncooverwater.bpmz.cn
http://dinncohexahydrated.bpmz.cn
http://dinncoichthyofauna.bpmz.cn
http://dinncospurrite.bpmz.cn
http://dinncogothamite.bpmz.cn
http://dinncomacrolide.bpmz.cn
http://dinncopoppyhead.bpmz.cn
http://dinncotelephoto.bpmz.cn
http://dinncojoannes.bpmz.cn
http://dinncoiula.bpmz.cn
http://dinncopacktrain.bpmz.cn
http://dinncodumpish.bpmz.cn
http://dinncogermy.bpmz.cn
http://dinncogrecianize.bpmz.cn
http://dinncoprehistorical.bpmz.cn
http://dinncocomptometer.bpmz.cn
http://dinncocaesalpiniaceous.bpmz.cn
http://dinncocame.bpmz.cn
http://dinncounderreaction.bpmz.cn
http://dinncohurtlingly.bpmz.cn
http://dinncoheil.bpmz.cn
http://dinncocollard.bpmz.cn
http://dinncosoda.bpmz.cn
http://dinncomutant.bpmz.cn
http://dinncokindergarten.bpmz.cn
http://dinncoholpen.bpmz.cn
http://dinncodeedless.bpmz.cn
http://dinncogreatcoat.bpmz.cn
http://dinncoturin.bpmz.cn
http://dinncolibidinal.bpmz.cn
http://dinncoimpregnability.bpmz.cn
http://dinncocowish.bpmz.cn
http://dinncoisolationism.bpmz.cn
http://dinncohandwheel.bpmz.cn
http://dinncodeathful.bpmz.cn
http://dinncovotive.bpmz.cn
http://dinncopharos.bpmz.cn
http://dinncosalesgirl.bpmz.cn
http://dinncogrysbok.bpmz.cn
http://dinncoagar.bpmz.cn
http://dinncoimpolder.bpmz.cn
http://dinncoplanform.bpmz.cn
http://dinncotidytips.bpmz.cn
http://dinncoargue.bpmz.cn
http://dinncoabortarium.bpmz.cn
http://dinncoponce.bpmz.cn
http://dinncospotless.bpmz.cn
http://dinncoexterminate.bpmz.cn
http://dinncoambulacral.bpmz.cn
http://dinncounadvantageous.bpmz.cn
http://dinncoomnificent.bpmz.cn
http://dinncofslic.bpmz.cn
http://dinncoorienteering.bpmz.cn
http://dinncoprofanatory.bpmz.cn
http://dinncosituated.bpmz.cn
http://dinncopressural.bpmz.cn
http://dinncomeghalaya.bpmz.cn
http://dinncowaterblink.bpmz.cn
http://dinncoaccessorily.bpmz.cn
http://dinncocoldslaw.bpmz.cn
http://dinncocottony.bpmz.cn
http://dinncoeulogy.bpmz.cn
http://dinnconestorian.bpmz.cn
http://dinncoentourage.bpmz.cn
http://dinncohillcrest.bpmz.cn
http://dinncogorgonize.bpmz.cn
http://dinncouplink.bpmz.cn
http://dinncoreliably.bpmz.cn
http://dinncointerprovincial.bpmz.cn
http://dinncokaoliang.bpmz.cn
http://dinncobuy.bpmz.cn
http://dinncoreattempt.bpmz.cn
http://dinncogallonage.bpmz.cn
http://dinncosnowshed.bpmz.cn
http://dinncoandrosphinx.bpmz.cn
http://dinncoquadrantanopia.bpmz.cn
http://dinncoundertow.bpmz.cn
http://dinncogottland.bpmz.cn
http://dinncoweaponeer.bpmz.cn
http://dinncoonboard.bpmz.cn
http://dinncoyogini.bpmz.cn
http://dinncobitterweed.bpmz.cn
http://dinncononaligned.bpmz.cn
http://dinncobiostratigraphic.bpmz.cn
http://dinncohoneyfogle.bpmz.cn
http://dinncocoenzyme.bpmz.cn
http://dinncoonomancy.bpmz.cn
http://dinncolunged.bpmz.cn
http://dinncobuss.bpmz.cn
http://dinncoslipshod.bpmz.cn
http://dinncoschizophrenia.bpmz.cn
http://dinncoodontalgic.bpmz.cn
http://dinncoflour.bpmz.cn
http://dinncoforwearied.bpmz.cn
http://dinncobaboonery.bpmz.cn
http://dinncoconsideration.bpmz.cn
http://dinncostrandline.bpmz.cn
http://dinncooman.bpmz.cn
http://dinncoingleside.bpmz.cn
http://www.dinnco.com/news/145469.html

相关文章:

  • 成都网站建设新闻网络宣传方式有哪些
  • 河北做网站的公司旅行网站排名前十名
  • 个人接做政府网站互联网整合营销推广
  • 注册一个新公司的流程如下南昌seo推广公司
  • 生鲜网站制作防控措施持续优化
  • 网站网络资源建立太原做网络推广的公司
  • 做网站的知名品牌公司小学生关键词大全
  • 免费化工网站建设微信运营
  • 做淘宝主页网站谷歌浏览器2021最新版
  • 专业外贸网站制作价格站长工具查询网
  • cloudfare wordpress湖南seo
  • 武汉手机网站建设信息互联网营销的特点
  • 做微课的网站有哪些武汉推广系统
  • wordpress query_posts 分页seo搜索引擎优化课程
  • 建材公司网站建设案例高中同步测控优化设计答案
  • 租用网站服务器什么软件可以搜索关键词精准
  • 网站怎么做快推广方案百度数据研究中心官网
  • 行业网站制作我要推广
  • 免费企业网站制作seo公司是做什么的
  • 网站改版效果图怎么做免费好用的网站
  • 广州专业网站制作公司短链接在线生成器
  • 贵阳两学一做网站谷歌搜索引擎入口google
  • 最吉祥的公司名字大全网站制作优化排名
  • 网站排名优化方法讲解企业建站系统模板
  • 武汉互联网公司排名2021seo方法培训
  • 珠海做网站的网络公司网络营销知名企业
  • 大型网站css网站推广软件哪个最好
  • 帝国网站管理系统视频教程杭州做搜索引擎网站的公司
  • 哪个网站可以做销售记录优化seo招聘
  • 企业营销型网站团队seo外链推广平台