In [68]:
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
In [69]:
clf_LDA = LinearDiscriminantAnalysis()
In [70]:
clf_LDA.fit(X_train, y_train)
Out[70]:
LinearDiscriminantAnalysis(n_components=None, priors=None, shrinkage=None,
              solver='svd', store_covariance=False, tol=0.0001)
In [71]:
y_predict = clf_LDA.predict(X_test)
In [72]:
y_predict
Out[72]:
array([1, 1, 1, 2, 0, 2, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1, 0, 0, 2, 1, 2, 1,
       0, 0, 2, 0, 0, 2, 0])
In [73]:
# Sada opet možemo da proverimo koliko je elemenata tačno klasifikovano 
y_predict == y_test
Out[73]:
array([ True,  True,  True,  True,  True,  True, False,  True,  True,
        True,  True,  True,  True,  True,  True,  True,  True,  True,
        True,  True,  True,  True,  True,  True,  True,  True,  True,
        True,  True,  True], dtype=bool)
In [74]:
# Tačnost u procentima iznosi:
sum (y_predict == y_test) / len(y_test)
Out[74]:
0.96666666666666667