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:
- 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