• 大小: 9.30M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-05-11
  • 语言: Python
  • 标签: pandas  and  das  实例  

资源简介


资源截图

代码片段和文件信息

import pydotplus
from sklearn.datasets import load_iris
from sklearn import tree
import collections

# Data Collection
X = [ [180 150]     
      [177 420]
      [136 351]
      [174 650]
      [141 281]]

Y = [‘man‘ ‘woman‘ ‘woman‘ ‘man‘ ‘woman‘]    
data_feature_names = [ ‘height‘ ‘hair length‘ ‘voice pitch‘ ]

# Training
clf = tree.DecisionTreeClassifier()
clf = clf.fit(XY)

# Visualize data
dot_data = tree.export_graphviz(clf
                                feature_names=data_feature_names
                                out_file=None
                                filled=True
                                rounded=True)
graph = pydotplus.graph_from_dot_data(dot_data)

colors = (‘turquoise‘ ‘orange‘)
edges = collections.defaultdict(list)

for edge in graph.get_edge_list():
    edges[edge.get_source()].append(int(edge.get_destination()))
print(edges)
for edge in edges:
    edges[edge].sort()    
    for i in range(2):
        dest = graph.get_node(str(edges[edge][i]))[0]
        dest.set_fillcolor(colors[i])

graph.write_png(‘tree.png‘)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-02-15 20:21  04-Python语言入门\
     目录           0  2020-02-15 19:09  04-Python语言入门\.ipynb_checkpoints\
     文件        9405  2020-02-15 20:21  04-Python语言入门\.ipynb_checkpoints\numpy_basic-checkpoint.ipynb
     文件      100183  2020-02-15 19:47  04-Python语言入门\.ipynb_checkpoints\pandas_basic-checkpoint.ipynb
     文件     1255483  2020-02-15 19:27  04-Python语言入门\.ipynb_checkpoints\python3.5_basic-checkpoint.ipynb
     文件         224  2020-02-15 19:55  04-Python语言入门\bin_data.npy
     文件         280  2020-02-02 10:13  04-Python语言入门\cdv_data.csv
     文件       88899  2020-02-15 19:40  04-Python语言入门\foo.csv
     文件       76663  2020-02-15 19:42  04-Python语言入门\foo.xlsx
     文件        9405  2020-02-15 20:21  04-Python语言入门\numpy_basic.ipynb
     文件      100183  2020-02-15 19:47  04-Python语言入门\pandas_basic.ipynb
     文件     1255483  2020-02-15 19:27  04-Python语言入门\python3.5_basic.ipynb
     文件         280  2020-02-15 19:55  04-Python语言入门\txt_data.txt
     目录           0  2020-02-02 20:45  05-传统机器学习初步\
     目录           0  2020-01-31 13:15  05-传统机器学习初步\.ipynb_checkpoints\
     文件     1271014  2020-01-31 13:42  05-传统机器学习初步\.ipynb_checkpoints\Apriori_Association_Rule_Mining-checkpoint.ipynb
     文件     1271014  2020-01-31 13:42  05-传统机器学习初步\Apriori_Association_Rule_Mining.ipynb
     文件        1708  2020-01-14 17:29  05-传统机器学习初步\SVR.py
     文件       38171  2020-01-14 19:08  05-传统机器学习初步\boston.csv
     文件        1124  2020-01-13 18:58  05-传统机器学习初步\decition_tree.py
     文件         996  2020-01-14 17:00  05-传统机器学习初步\k-means.py
     文件        2301  2020-01-14 19:21  05-传统机器学习初步\linear_regression.py
     目录           0  2020-02-02 20:57  05-传统机器学习初步\multi-variate_linear_regression\
     目录           0  2020-02-02 20:51  05-传统机器学习初步\multi-variate_linear_regression\.ipynb_checkpoints\
     文件        4276  2020-02-02 20:57  05-传统机器学习初步\multi-variate_linear_regression\.ipynb_checkpoints\multi-variate_linear_regression-checkpoint.ipynb
     文件         165  2020-02-02 20:49  05-传统机器学习初步\multi-variate_linear_regression\BloodPressure.csv
     文件        4276  2020-02-02 20:57  05-传统机器学习初步\multi-variate_linear_regression\multi-variate_linear_regression.ipynb
     文件         177  2020-02-02 20:47  05-传统机器学习初步\multi-variate_linear_regression\readme.txt
     文件      302908  2020-01-31 13:00  05-传统机器学习初步\store_data.csv
     文件       39822  2020-01-31 11:24  05-传统机器学习初步\tree.png
     文件       73123  2020-01-13 19:57  05-传统机器学习初步\xclara.csv
............此处省略158个文件信息

评论

共有 条评论