“Pohon Keputusan Python” Kode Jawaban

KEPUTUSAN BELAJAR SAMBUNG

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)


Uninterested Unicorn

Pohon Keputusan Python

# Create Decision Tree classifer object
clf = DecisionTreeClassifier(criterion="entropy", max_depth=3)

# Train Decision Tree Classifer
clf = clf.fit(X_train,y_train)

#Predict the response for test dataset
y_pred = clf.predict(X_test)

# Model Accuracy, how often is the classifier correct?
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))
Ruben Visser

KEPUTUSAN BELAJAR SAMBUNG

tree.plot_tree(clf) 
Uninterested Unicorn

Jawaban yang mirip dengan “Pohon Keputusan Python”

Pertanyaan yang mirip dengan “Pohon Keputusan Python”

Lebih banyak jawaban terkait untuk “Pohon Keputusan Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya