“Python pohon keputusan” 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

Python pohon keputusan

# 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

pohon keputusan

from sklearn.datasets import load_iris
>>> from sklearn import tree
>>> X, y = load_iris(return_X_y=True)
>>> clf = tree.DecisionTreeClassifier()
>>> clf = clf.fit(X, y)
Tame Tern

KEPUTUSAN BELAJAR SAMBUNG

clf.predict([[2., 2.]])
Uninterested Unicorn

KEPUTUSAN BELAJAR SAMBUNG

from sklearn.datasets import load_iris
from sklearn import tree
X, y = load_iris(return_X_y=True)
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, y)
Uninterested Unicorn

Jawaban yang mirip dengan “Python pohon keputusan”

Pertanyaan yang mirip dengan “Python pohon keputusan”

Lebih banyak jawaban terkait untuk “Python pohon keputusan” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya