Ejemplo 1: decisiontreeclassifier sklearn
from sklearn.tree import DecisionTreeClassifier
Ejemplo 2: decisión de aprender a dibujar
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import export_text
iris = load_iris()
decision_tree = DecisionTreeClassifier(random_state=0, max_depth=2)
decision_tree = decision_tree.fit(iris.data, iris.target)
r = export_text(decision_tree, feature_names=iris['feature_names'])
print(r)
Ejemplo 3: criterio de gini del clasificador del árbol de decisiones de scikit
from sklearn.tree import DecisionTreeClassifier
from sklearn import metrics
# Max depth Decision tree classifier using gini criterion
clf_gini_max = DecisionTreeClassifier(random_state=50, criterion='gini', max_depth=None)
clf_gini_max = clf_gini_max.fit(X_train,Y_train)
Y_pred = clf_gini_max.predict(X_test)
training_accuracy = clf_gini_max.score(X_train,Y_train)
testing_accuracy = clf_gini_max.score(X_test,Y_test)
print(training_accuracy)
print(testing_accuracy)
Ejemplo 4: árbol de decisiones de scikit learn
from sklearn import tree
X = [[0, 0], [1, 1]]
Y = [0, 1]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, Y)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)