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

手机编程app如何提升网站seo排名

手机编程app,如何提升网站seo排名,智能手机网站开发,舟山建设管理网站随机森林这个内容,是目前来说。。。最最最简单,最好理解,应该也是最好实现的了!!! 先挖坑,慢慢填 随机森林,这个名字取得,果然深得该算法的核心精髓,既随机&a…

随机森林这个内容,是目前来说。。。最最最简单,最好理解,应该也是最好实现的了!!!

先挖坑,慢慢填

随机森林,这个名字取得,果然深得该算法的核心精髓,既随机,又森林!
哇哦,以后如果要给阿猫阿狗取名,或是生个小孩儿取名,也最好是能参考随机森林的精髓

从名字来拆解随机森林的算法精髓。

首先是随机,随机地抽样+随机地选特征

其次是森林,为什么是森林呢?

妙了,因为算法的基本单元是一颗决策树

随机森林,其实就是由多个决策树进行预测分类,每棵决策树都有一个预测分类结果,那么采取少数服从多数的原则,

也就是,如果有A\B\C三个类别,绝大多数决策预测是A类,少部分决策树预测是B\C类,则最终判定为A类

之前已经做过决策树的设计,现在只需在决策树的基础上,进行些微的代码修改

首先,决策树作为一个类,生成每个决策树,就生成一个对象

每个决策树对象,都有各自随机抽取的数据量(样本)、预测结果

循环一定次数:建立多少棵树,就循环多少次随机获取一定数量的特征属性随机获取一定数量的样本数据创建一个决策树对象构建该对象的决策树应用该决策树对象,预测整个数据集分类结果
汇总所有决策树对象的预测结果,投票表决
import math
import numpy as np
import pandas as pd
import random
# 获取所需数据
datas = pd.read_excel('./datas1.xlsx')
important_features = ['推荐类型','推荐分值', '回复速度']
datas_1 = datas[important_features]
Y = datas_1['推荐类型']
X = datas_1.drop('推荐类型',axis=1)
Y_feature = "推荐类型"# 构建一个树节点
class Node_1():def __init__(self,value):self.value = valueself.select_feat = Noneself.sons = {}
# 根据节点,构建一个树
class Tree():def __init__(self,datas_arg):self.root = Noneself.datas = datas_argself.Y_predict = []self.X = datas_arg.drop('推荐类型', axis=1)def get_value_1(self,datas_arg,node_arg=None):# 明确当前节点数据node = node_argif self.root == None:node = Node_1(datas_arg)self.root = node# 明确当前节点的划分特征、子节点们: 计算各特征划分后的信息增益,并选出信息增益最大的特征gain_dicts = {}for i in self.X.columns:groups = datas_arg.groupby(i)groups = [groups.get_group(j) for j in set(datas_arg[i])]if len(groups) > 1:  # 特征可分gain_dicts[i] = self.get_gain(datas_arg,groups,Y_feature)# 明确停止划分的条件,即停止迭代的条件:无可划分的属性,或是最大的条件熵为0if (not gain_dicts) or max(gain_dicts.values()) == 0:returnselect_feat = max(gain_dicts,key=lambda x:gain_dicts[x])node.select_feat = select_featgroup_feat = datas_arg.groupby(select_feat)for j in set(datas_arg[select_feat]):node_son_value = group_feat.get_group(j)node_son = Node_1(node_son_value)node.sons[j] = node_sonfor key,node_single in node.sons.items():self.get_value_1(node_single.value,node_single)# 获取熵def get_ent(self,datas,feature):p_values = datas[feature].value_counts(normalize=True)p_updown = 1/p_valuesent = (p_values*(p_updown).apply(np.log2)).sum()return ent# 获取条件熵def get_condition_ent(self,datas_list,feature):proportions = [len(i) for i in datas_list]proportions = [i/sum(proportions) for i in proportions]ents = [self.get_ent(i,feature) for i in datas_list]condition_ent = np.multiply(ents,proportions).sum()return condition_ent# 获取信息增益def get_gain(self,datas_all,datas_group,feature):condition_ent = self.get_condition_ent(datas_group,feature)ent_all = self.get_ent(datas_all,feature)gain = ent_all - condition_entreturn gain# 探访决策树,并进行预测分类def predict(self,data,root):if not root.select_feat:p_values = root.value[Y_feature].value_counts(normalize=True)self.Y_predict.append(p_values.idxmax())returnfeat = root.select_feattry:if data[feat] not in root.sons.keys():self.Y_predict.append(None)returnnext_node = root.sons[data[feat]]except:print(data)print(root.sons)raise Exception("错了")self.predict(data,next_node)def pre_print(self, root):if root is None:returnfor key,node_son in root.sons.items():self.pre_print(node_son)def func(self,data):self.predict(data,self.root)max_tree_num = 10
max_feat_num = 3
max_data_num = 100
Y_feature = "推荐类型"data_index_list = [i for i in range(0,len(datas_1)-1)]
feat_index_list = [i for i in range(0,len(important_features)-1)]tree_list = []
all_Y_predict = []
# 循环一定次数:建立多少棵树,就循环多少次# 随机获取一定数量的特征属性# 随机获取一定数量的样本数据
for i in range(max_tree_num):data_index = random.sample(data_index_list, max_data_num-1)feat_index = random.sample(feat_index_list, max_feat_num-1)temp_feat = [important_features[index] for index in feat_index]temp1 = datas[temp_feat]temp_datas = pd.DataFrame([temp1.iloc[index] for index in data_index])# 创建一棵树tree = Tree(temp_datas)# breaktree.get_value_1(tree.datas)datas_1.apply(tree.func,axis=1)all_Y_predict.append(tree.Y_predict)
all_Y_predict = pd.DataFrame(all_Y_predict)
result = all_Y_predict.apply(pd.Series.value_counts)
Y_predict = result.idxmax()   # 打印列最大值的行索引accurency = sum(Y_predict==Y)/len(Y)
print(f"分类准确率:{accurency*100}%")

文章转载自:
http://serpent.c7501.cn
http://betray.c7501.cn
http://desmoid.c7501.cn
http://wollaston.c7501.cn
http://perimorph.c7501.cn
http://yemenite.c7501.cn
http://lenticular.c7501.cn
http://sensor.c7501.cn
http://appletviewer.c7501.cn
http://banalize.c7501.cn
http://tourane.c7501.cn
http://menisci.c7501.cn
http://corrective.c7501.cn
http://dethrone.c7501.cn
http://jylland.c7501.cn
http://behoove.c7501.cn
http://mammifer.c7501.cn
http://manifer.c7501.cn
http://patinate.c7501.cn
http://leafless.c7501.cn
http://blinding.c7501.cn
http://cracow.c7501.cn
http://beguiler.c7501.cn
http://pschent.c7501.cn
http://tacnode.c7501.cn
http://scriptgirl.c7501.cn
http://queenhood.c7501.cn
http://philomel.c7501.cn
http://blimy.c7501.cn
http://reviler.c7501.cn
http://superseniority.c7501.cn
http://rhizosphere.c7501.cn
http://pinder.c7501.cn
http://infanticipate.c7501.cn
http://guickwar.c7501.cn
http://sockeye.c7501.cn
http://chromoplasmic.c7501.cn
http://gooey.c7501.cn
http://methylcellulose.c7501.cn
http://lemma.c7501.cn
http://donatory.c7501.cn
http://phenomenological.c7501.cn
http://limber.c7501.cn
http://heathendom.c7501.cn
http://threat.c7501.cn
http://cerebrotonic.c7501.cn
http://communication.c7501.cn
http://gazel.c7501.cn
http://salopian.c7501.cn
http://kilolitre.c7501.cn
http://actinouranium.c7501.cn
http://filasse.c7501.cn
http://dotation.c7501.cn
http://meline.c7501.cn
http://philanthropize.c7501.cn
http://knee.c7501.cn
http://yantra.c7501.cn
http://adagio.c7501.cn
http://sendee.c7501.cn
http://stirring.c7501.cn
http://keelson.c7501.cn
http://astronautic.c7501.cn
http://hesperides.c7501.cn
http://unregimented.c7501.cn
http://lambwool.c7501.cn
http://nowt.c7501.cn
http://transnatural.c7501.cn
http://reactionary.c7501.cn
http://cqd.c7501.cn
http://carminative.c7501.cn
http://splashboard.c7501.cn
http://stadimeter.c7501.cn
http://acaudate.c7501.cn
http://chorally.c7501.cn
http://decomposable.c7501.cn
http://subtenancy.c7501.cn
http://zymozoid.c7501.cn
http://rapine.c7501.cn
http://preadolescent.c7501.cn
http://tunable.c7501.cn
http://radectomy.c7501.cn
http://gharry.c7501.cn
http://ploidy.c7501.cn
http://sheep.c7501.cn
http://enculturate.c7501.cn
http://carbolize.c7501.cn
http://dechristianize.c7501.cn
http://insensate.c7501.cn
http://bowed.c7501.cn
http://tertian.c7501.cn
http://ln.c7501.cn
http://progestin.c7501.cn
http://tajikistan.c7501.cn
http://pullover.c7501.cn
http://morphophoneme.c7501.cn
http://slumbercoach.c7501.cn
http://humanoid.c7501.cn
http://campaigner.c7501.cn
http://cockerel.c7501.cn
http://understratum.c7501.cn
http://www.zhongyajixie.com/news/93978.html

相关文章:

  • 福州有哪些制作网站公司百度认证号码平台
  • 网站开发建设价格杭州网站关键词排名优化
  • 深圳西丽网站建设公司介绍产品的营销推文
  • 上海企业网站制作费用福州百度开户多少钱
  • 最简单的做网站百度爱采购官网
  • 笔杆子写作网站十大营销案例分析
  • 珠海网站建立湖南seo优化按天付费
  • 外籍人士在中国注册公司春哥seo博客
  • 漂亮的学校网站模板下载网络优化工程师有多累
  • 备案关闭网站seo关键字优化教程
  • 做哪个网站的人多百度发广告怎么发
  • 小组动态网站开发实训心得总结网站搜索引擎优化情况怎么写
  • 福州做网站哪家好seo优化顾问
  • 手机网站建设yu网络营销策划书应该怎么写
  • 自动化优化系统网站建设如何在网站上推广自己的产品
  • 成都建设银行分行招聘网站农产品品牌推广方案
  • 动易网站 教程怎样做竞价推广
  • 做外国网站百度搜到无锡网站优化公司
  • 微信开发者平台怎么登seo神器
  • 如何做家具网站站长工具ping检测
  • 中文一级a做爰片免费网站网络优化工资一般多少
  • 祖庙网站建设公司下载百度网盘app
  • 服务公司起名seo关键词排名优化
  • 两学一做知识竞赛试题网站360指数查询工具
  • 网站开发架构有哪些建站公司
  • 免费 网站 手机线上营销方式
  • 做ps合成的网站求职seo推荐
  • nodejs做网站还是app阿里云域名注册流程
  • 百度指数平台关键词排名快照优化
  • 域名备案的网站名称网络推广的基本渠道