美文网首页
花瓣的线性回归

花瓣的线性回归

作者: 乔治大叔 | 来源:发表于2021-01-28 16:51 被阅读0次
    import pandas as pd
    #用于数据预处理/特征工程的工具包
    from sklearn import tree
    from sklearn.datasets import load_iris
    import pydotplus
    
    iris = load_iris()
    
    iris_feature_name = iris.feature_names
    iris_feature = iris.data
    iris_target_name = iris.target_names
    iris_target = iris.target
    
    # print(iris_feature_name)
    # print(iris_feature)
    # print(iris_target_name)
    # print(iris_target)
    
    
    clf = tree.DecisionTreeClassifier(max_depth=4)
    clf = clf.fit(iris_feature,iris_target)
    # print(clf)
    
    dot_data = tree.export_graphviz(clf,
                                    out_file=None,
                                    feature_names=iris_feature_name,
                                    class_names=iris_target_name,
                                    filled=True,
                                    rounded=True)
    graph = pydotplus.graph_from_dot_data(dot_data)
    graph.write_png('DecisionTree.png')
    
    

    相关文章

      网友评论

          本文标题:花瓣的线性回归

          本文链接:https://www.haomeiwen.com/subject/xvhwbctx.html