47
правок
Изменения
м
Нет описания правки
===Код===
from sklearn.datasets import load_iris
from sklearn import svm, metrics
from sklearn.utils import shuffle
from sklearn.ensemble import RandomForestClassifier
import numpy
iris=load_iris()
X = iris.data
Y = iris.target
X, Y = shuffle(X, Y)
n = len(iris.data)
train = n // 2
clf = RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0)
clf.fit(X[:train], Y[:train])
expected = Y[train:]
predicted = clf.predict(X[train:])
print("Classification report for classifier %s:\n%s\n"
% (clf, metrics.classification_report(expected, predicted)))
type precision recall f1-score support
0 1.00 1.00 1.00 28
1 0.95 0.88 0.91 24
2 0.88 0.96 0.92 23
avg / total 0.95 0.95 0.95 75
==ImageNet==