其他分享
首页 > 其他分享> > Udacity term one - decision tree

Udacity term one - decision tree

作者:互联网

def classify(features_train, labels_train):
    ### import the sklearn module for GaussianNB
    from sklearn import tree
    ### create classifier
    clf = tree.DecisionTreeClassifier(min_samples_split=2)
    ### fit the classifier on the training features and labels
    clf.fit(features_train, labels_train)
    ### return the fit classifier
    return clf

在这里插入图片描述

accuracy=0.908

change min_samples_split=50.

def classify(features_train, labels_train):
    ### import the sklearn module for GaussianNB
    from sklearn import tree
    ### create classifier
    clf = tree.DecisionTreeClassifier(min_samples_split=50)
    ### fit the classifier on the training features and labels
    clf.fit(features_train, labels_train)
    ### return the fit classifier
    return clf
accuracy=0.912

在这里插入图片描述
to do list:

  1. learn more about the D.T. classifier:

class sklearn.tree.DecisionTreeClassifier(criterion=’gini’, splitter=’best’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=None, random_state=None, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, class_weight=None, presort=False)

标签:term,features,min,labels,tree,Udacity,train,classifier,###
来源: https://blog.csdn.net/xiaobing98/article/details/101367664