47
правок
Изменения
м
Ага.
Нет описания правки
===Код===
from sklearn.datasets import fetch_mldata
import random
from sklearn.utils import shuffle
from numpy import arange
mnist = fetch_mldata('MNIST original')
indices = arange(len(mnist.data))
randidx = random.sample(list(indices), 500)
mnist.data = mnist.data[randidx]
mnist.target = mnist.target[randidx]
X = mnist.data
Y = mnist.target
train = len(X)//2
clf = DecisionTreeClassifier(criterion="entropy", max_depth=5)
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)))
==CIFAR-10==