![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python和机器学习
m0_68479570
这个作者很懒,什么都没留下…
展开
-
Python 10 函数:求基尼指数
Q:(选做) 自己编写求Gini指数的函数,并与纸质作业比较,验证函数正确性。ps:最简单的求解函数,只是方便计算简单题目def gini_index(x,y,i): # x:feature list # y:result list # i:x里的第i列的属性 x1,y11,y12 = [],[],[] for j in range(len(x)): if x[j][i]==1: x1.append(1原创 2022-05-15 15:51:18 · 843 阅读 · 0 评论 -
Python 09 决策树分类边界
Q:采用 Iris 数据集的前两个属性和前100个数据集,构建决策树,并画出类似于书籍图4.11的分类边界构建决策树from matplotlib import pyplot as pltfrom sklearn.datasets import load_irisfrom sklearn.tree import DecisionTreeClassifierfrom sklearn.tree import DecisionTreeRegressorfrom sklearn.tree imp.原创 2022-05-15 10:56:20 · 766 阅读 · 0 评论 -
Python 08 决策树分类
Q:对数据集,分别采用信息增益和Gini指标,利用sklearn的DecisionTreeClassifier 函数构建决策树代码:from matplotlib import pyplot as plt# 特征a1 = [1,1,1,1,1,0,0,0,1,1]a2 = [0,1,1,0,1,0,0,0,1,1]X=[]for i in range(len(a1)): x = [a1[i],a2[i]] X.append(x)# 类别Y = [1,1,1,.原创 2022-05-15 10:31:31 · 388 阅读 · 0 评论