“Sklearn Tree Greadtreeclastier Görselleştirme” Kodu Cevaplar

Karar Ağacı Sınıflandırıcı Sklearn
from sklearn.datasets import load_iris
from sklearn.model_selection import cross_val_score
from sklearn.tree import DecisionTreeClassifier
clf = DecisionTreeClassifier(random_state=0)
iris = load_iris()
cross_val_score(clf, iris.data, iris.target, cv=10)
Sklearn Ağacı KararıTreeclassier Görselleştirme
1
2
3
4
5
6
7
8
9
10
11
12
from pydotplus import graph_from_dot_data
from sklearn.tree import export_graphviz
 
dot_data = export_graphviz(clf_tree, filled=True, rounded=True,
                                    class_names=['Setosa',
                                                'Versicolor',
                                                'Virginica'],
                                    feature_names=['petal length',
                                                'petal width'],
                                    out_file=None)
graph = graph_from_dot_data(dot_data)
graph.write_png('/Users/apple/Downloads/tree.png')