Sveučilište u Zagrebu
Fakultet elektrotehnike i računarstva

Strojno učenje

http://www.fer.unizg.hr/predmet/su

Ak. god. 2015./2016.

Bilježnica 10: Vrednovanje modela

(c) 2015 Jan Šnajder

Verzija: 0.1 (2015-12-19)


In [2]:
# Učitaj osnovne biblioteke...
import scipy as sp
import sklearn
import pandas as pd
%pylab inline


Populating the interactive namespace from numpy and matplotlib

Sadržaj

  • Matrica zabune

  • Osnovne mjere

  • F-mjera

  • Višeklasna klasifikacija

  • Procjena pogreške

  • Statističko testiranje

  • Usporedba klasifikatora

Matrica zabune


In [42]:
y_test = sp.random.choice((0,1), size=10); y_test


Out[42]:
array([1, 0, 1, 0, 1, 0, 1, 0, 1, 0])

In [50]:
y_pred = sp.random.choice((0,1), size=10); y_pred


Out[50]:
array([0, 0, 0, 1, 0, 0, 1, 1, 0, 1])
  • [Skica: retci -> klasifikacija, stupci -> stvarno]

In [105]:
def cm(y_true, y_pred):
    tp = 0
    fp = 0
    fn = 0
    tn = 0
    for (t, p) in zip(y_true, y_pred):
        if t == 0 and p == 1: fp += 1
        elif t == 1 and p == 0: fn += 1
        elif t == 1 and p == 1: tp += 1
        else: tn += 1
    return sp.array([[tp, fp], [fn, tn]])

In [106]:
cm(y_test, y_pred)


Out[106]:
array([[1, 3],
       [4, 2]])

In [102]:
from sklearn.metrics import confusion_matrix
  • [Skica: retci -> stvarno, stupci -> klasifikacija]

In [103]:
confusion_matrix(y_test, y_pred)


Out[103]:
array([[2, 3],
       [4, 1]])

In [104]:
confusion_matrix(y_test, y_pred, labels=[1,0])


Out[104]:
array([[1, 4],
       [3, 2]])

Osnovne mjere

  • [Skica: TP-FP-TN-FN]
  • Točnost (engl. accuracy)
$$ \mathrm{Acc} = \frac{\mathrm{TP}+\mathrm{TN}}{N} = \frac{\mathrm{TP}+\mathrm{TN}}{\mathrm{TP}+\mathrm{TN}+\mathrm{FP}+\mathrm{FN}} $$
  • Preciznost (engl. precision)
$$ \mathrm{P} = \frac{\mathrm{TP}}{\mathrm{TP}+\mathrm{FP}} $$
  • Odziv (engl. recall), true positive rate, specificity
$$ \mathrm{R} = \mathrm{TPR} = \frac{\mathrm{TP}}{\mathrm{TP}+\mathrm{FN}} $$
  • Fall-out, false positive rate
$$ \mathrm{FPR} = \frac{\mathrm{FP}}{\mathrm{FP}+\mathrm{TN}} $$

Primjer


In [107]:
cm(y_test, y_pred)


Out[107]:
array([[1, 3],
       [4, 2]])

In [121]:
from sklearn.metrics import accuracy_score, precision_score, recall_score

In [122]:
accuracy_score(y_test, y_pred)


Out[122]:
0.29999999999999999

In [94]:
precision_score(y_test, y_pred)


Out[94]:
0.25

In [112]:
recall_score(y_test, y_pred)


Out[112]:
0.20000000000000001

Primjer: Titanic dataset


In [604]:
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import Imputer

titanic_df = pd.read_csv("../data/titanic-train.csv")
titanic_df.drop(['PassengerId'], axis=1, inplace=True)
titanic_df1 = titanic_df[['Pclass', 'Sex', 'Age','Survived']]
titanic_X = titanic_df[['Pclass', 'Sex', 'Age']].as_matrix()

titanic_y = titanic_df['Survived'].as_matrix()

le = LabelEncoder()
titanic_X[:,1] = le.fit_transform(titanic_X[:,1])

imp = Imputer(missing_values='NaN', strategy='mean', axis=0)
titanic_X = imp.fit_transform(titanic_X)

In [605]:
titanic_X


Out[605]:
array([[  3.        ,   1.        ,  22.        ],
       [  1.        ,   0.        ,  38.        ],
       [  3.        ,   0.        ,  26.        ],
       ..., 
       [  3.        ,   0.        ,  29.69911765],
       [  1.        ,   1.        ,  26.        ],
       [  3.        ,   1.        ,  32.        ]])

In [497]:
titanic_y


Out[497]:
array([0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1,
       1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0,
       0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 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0, 0, 0,
       0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0,
       1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1,
       0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1,
       0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1,
       1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
       0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0,
       1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0])

In [606]:
shape(titanic_X), shape(titanic_y)


Out[606]:
((891, 3), (891,))

In [607]:
from sklearn import cross_validation
X_train, X_test, y_train, y_test = cross_validation.train_test_split(titanic_X, titanic_y, train_size=2.0/3, random_state=42)

In [608]:
from sklearn.linear_model import LogisticRegression
lr = LogisticRegression(C=1)
lr.fit(X_train, y_train)


Out[608]:
LogisticRegression(C=1, class_weight=None, dual=False, fit_intercept=True,
          intercept_scaling=1, penalty='l2', random_state=None, tol=0.0001)

In [609]:
lr.predict(X_train)


Out[609]:
array([0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1,
       0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,
       0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1,
       0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0,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0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1,
       0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1,
       1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0,
       1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1,
       0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1,
       1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0])

In [610]:
y_pred_lr = lr.predict(X_test); y_pred_lr


Out[610]:
array([0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1,
       0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0,
       0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0,
       1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1,
       0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0,
       0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0,
       0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0,
       0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,
       0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0,
       0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1,
       0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
       0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
       0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0])

In [611]:
y_test


Out[611]:
array([1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1,
       0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0,
       1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0,
       0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0,
       0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0,
       0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0,
       1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0,
       1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1,
       0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
       0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0,
       0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0])

In [612]:
cm(y_test, y_pred_lr)


Out[612]:
array([[ 84,  23],
       [ 36, 154]])

In [613]:
accuracy_score(y_test, y_pred_lr)


Out[613]:
0.80134680134680136

In [614]:
lr.score(X_test, y_test)


Out[614]:
0.80134680134680136

In [615]:
lr.score(X_train, y_train)


Out[615]:
0.78282828282828287

In [616]:
precision_score(y_test, y_pred_lr, pos_label=1)


Out[616]:
0.78504672897196259

In [617]:
recall_score(y_test, y_pred_lr, pos_label=1)


Out[617]:
0.69999999999999996

In [618]:
from sklearn.svm import SVC
svm = SVC(C=1)
svm.fit(X_train, y_train)


Out[618]:
SVC(C=1, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0,
  kernel='rbf', max_iter=-1, probability=False, random_state=None,
  shrinking=True, tol=0.001, verbose=False)

In [619]:
svm.score(X_test, y_test)


Out[619]:
0.79797979797979801

In [620]:
y_pred_svm = svm.predict(X_test); y_pred_svm


Out[620]:
array([0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0,
       1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
       0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0,
       0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0,
       0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0,
       0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
       1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1,
       0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
       0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0,
       0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0])

In [621]:
cm(y_test, y_pred_svm)


Out[621]:
array([[ 81,  21],
       [ 39, 156]])

In [622]:
precision_score(y_test, y_pred_svm, pos_label=1)


Out[622]:
0.79411764705882348

In [623]:
recall_score(y_test, y_pred_svm, pos_label=1)


Out[623]:
0.67500000000000004

Variranje klasifikacijskog praga


In [624]:
y_scores_lr = lr.predict_proba(X_test)[:,1]; y_scores_lr


Out[624]:
array([ 0.11923502,  0.22993797,  0.13507455,  0.80220377,  0.6158762 ,
        0.87165829,  0.55991501,  0.14210781,  0.60888291,  0.88275876,
        0.38063556,  0.09882394,  0.55991501,  0.11877033,  0.21715615,
        0.88725575,  0.36343027,  0.55991501,  0.24053704,  0.34656751,
        0.1283373 ,  0.3911077 ,  0.59830943,  0.13507455,  0.11923502,
        0.15322775,  0.37027331,  0.22993797,  0.16505043,  0.55518769,
        0.13680483,  0.58764368,  0.40629524,  0.55991501,  0.13855373,
        0.12347423,  0.41234677,  0.55991501,  0.86492085,  0.11923502,
        0.25705129,  0.12032082,  0.11923502,  0.11923502,  0.50385484,
        0.14210781,  0.13680483,  0.12999426,  0.1283373 ,  0.31083838,
        0.64672175,  0.82240026,  0.10419704,  0.47406202,  0.07448779,
        0.88427478,  0.22733998,  0.82666263,  0.72570231,  0.59830943,
        0.13336276,  0.78533104,  0.74574443,  0.40629524,  0.11923502,
        0.65674983,  0.25705129,  0.12032082,  0.14032136,  0.82240026,
        0.75129016,  0.88427478,  0.41950388,  0.84866877,  0.12999426,
        0.10982668,  0.55700589,  0.87810704,  0.71681814,  0.51857737,
        0.14210781,  0.74294119,  0.84676714,  0.11923502,  0.31718458,
        0.27136544,  0.86319052,  0.86492085,  0.37716885,  0.11923502,
        0.15514887,  0.63314577,  0.30145144,  0.11923502,  0.11923502,
        0.12188874,  0.34323913,  0.09751976,  0.72276025,  0.12347423,
        0.29222777,  0.11127515,  0.88275876,  0.10697927,  0.11800159,
        0.12669839,  0.71079964,  0.34656751,  0.11877033,  0.37027331,
        0.86543785,  0.13421635,  0.86543785,  0.38411448,  0.40629524,
        0.13507455,  0.27136544,  0.21715615,  0.76213657,  0.49280715,
        0.25146514,  0.86144157,  0.79748575,  0.31772927,  0.12669839,
        0.3876053 ,  0.82876331,  0.42669502,  0.55991501,  0.13336276,
        0.55991501,  0.11923502,  0.23334869,  0.64672175,  0.33992609,
        0.61238534,  0.86543785,  0.12032082,  0.10147895,  0.60184463,
        0.13336276,  0.69853825,  0.23785629,  0.21466232,  0.52592815,
        0.72862487,  0.23255671,  0.15132494,  0.86543785,  0.10014362,
        0.11923502,  0.1283373 ,  0.13855373,  0.55991501,  0.11923502,
        0.11923502,  0.11923502,  0.55991501,  0.72276025,  0.55154691,
        0.12916352,  0.40629524,  0.2097373 ,  0.86543785,  0.11923502,
        0.28919029,  0.25146514,  0.86543785,  0.13166937,  0.11127515,
        0.43030245,  0.7726531 ,  0.38411448,  0.63314577,  0.14032136,
        0.11923502,  0.52959954,  0.77523036,  0.65008007,  0.35158827,
        0.25146514,  0.11572119,  0.12507741,  0.64334889,  0.42669502,
        0.35326924,  0.23519616,  0.11923502,  0.40629524,  0.70470592,
        0.10982668,  0.22476278,  0.14032136,  0.12032082,  0.67960578,
        0.85608195,  0.85055098,  0.22220639,  0.88577373,  0.62627611,
        0.07865321,  0.55882256,  0.79985595,  0.43788785,  0.13507455,
        0.55991501,  0.12032082,  0.38411448,  0.11923502,  0.0912268 ,
        0.4159209 ,  0.11877033,  0.85967389,  0.11923502,  0.55991501,
        0.16915072,  0.7540325 ,  0.33334701,  0.7540325 ,  0.11923502,
        0.11923502,  0.75675439,  0.13855373,  0.40629524,  0.12669839,
        0.75675439,  0.13166937,  0.51115902,  0.75675439,  0.57329534,
        0.22220639,  0.87967501,  0.11923502,  0.55991501,  0.11923502,
        0.58764368,  0.79985441,  0.60184463,  0.84290519,  0.16914937,
        0.13680483,  0.70470592,  0.11923502,  0.59476398,  0.11200564,
        0.12188874,  0.11923502,  0.12999426,  0.13166937,  0.33008146,
        0.55882256,  0.21590663,  0.11923502,  0.13166937,  0.33662863,
        0.12347423,  0.13166937,  0.82454163,  0.21715615,  0.74294119,
        0.87810704,  0.33662863,  0.71079964,  0.12347423,  0.40629524,
        0.28919029,  0.14032136,  0.41234677,  0.49981799,  0.11923502,
        0.66006507,  0.21715615,  0.20013775,  0.37716885,  0.73727439,
        0.12032082,  0.13855373,  0.23334869,  0.84866877,  0.2097373 ,
        0.12507741,  0.13507455,  0.86543785,  0.09245544,  0.25146514,
        0.1712311 ,  0.55991501,  0.11923502,  0.31084043,  0.16505043,
        0.13680483,  0.10351154,  0.66006507,  0.55991501,  0.13336276,
        0.32359951,  0.11923502])

In [625]:
print precision_score(y_test, y_pred_lr)
print recall_score(y_test, y_pred_lr)


0.785046728972
0.7

In [626]:
threshold = 0.4
y_pred_lr_tweaked = map(lambda s : 1 if s > threshold else 0, y_scores_lr)
print y_pred_lr_tweaked


[0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0]

In [627]:
print precision_score(y_test, y_pred_lr_tweaked)
print recall_score(y_test, y_pred_lr_tweaked)


0.752
0.783333333333

Krivulja preciznost-odziv


In [628]:
from sklearn.metrics import precision_recall_curve

In [629]:
pr, re, _ = precision_recall_curve(y_test, y_scores_lr, pos_label=1)

In [630]:
pr


Out[630]:
array([ 0.40955631,  0.40753425,  0.40893471,  0.41034483,  0.41176471,
        0.41319444,  0.41463415,  0.41608392,  0.41901408,  0.42198582,
        0.42348754,  0.425     ,  0.4265233 ,  0.42753623,  0.46747967,
        0.475     ,  0.4789916 ,  0.47863248,  0.48275862,  0.48908297,
        0.49557522,  0.49777778,  0.5045045 ,  0.51612903,  0.5258216 ,
        0.52830189,  0.53623188,  0.54679803,  0.55276382,  0.56410256,
        0.57291667,  0.57591623,  0.57894737,  0.57671958,  0.57754011,
        0.58064516,  0.58378378,  0.58695652,  0.59016393,  0.59668508,
        0.6       ,  0.60335196,  0.61714286,  0.62427746,  0.62790698,
        0.63157895,  0.63313609,  0.63690476,  0.64457831,  0.64848485,
        0.65243902,  0.65644172,  0.67295597,  0.68152866,  0.69032258,
        0.69934641,  0.70394737,  0.70860927,  0.71333333,  0.7114094 ,
        0.71621622,  0.71428571,  0.71917808,  0.71724138,  0.72222222,
        0.72535211,  0.72340426,  0.72142857,  0.73188406,  0.73722628,
        0.74264706,  0.74074074,  0.7443609 ,  0.75572519,  0.76153846,
        0.75590551,  0.75396825,  0.752     ,  0.77118644,  0.76724138,
        0.77391304,  0.77192982,  0.78571429,  0.78378378,  0.78181818,
        0.77981651,  0.78703704,  0.78504673,  0.79245283,  0.79047619,
        0.79807692,  0.80582524,  0.80392157,  0.81188119,  0.82      ,
        0.82828283,  0.83505155,  0.86746988,  0.86585366,  0.8625    ,
        0.87341772,  0.87012987,  0.88      ,  0.87837838,  0.87671233,
        0.875     ,  0.88732394,  0.91304348,  0.92647059,  0.92424242,
        0.92307692,  0.9375    ,  0.93548387,  0.93442623,  0.95      ,
        0.94827586,  0.94642857,  0.96363636,  0.96226415,  0.96153846,
        0.96078431,  0.96      ,  0.95833333,  0.95744681,  0.97826087,
        0.97727273,  1.        ,  1.        ,  1.        ,  1.        ,
        1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
        1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
        1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
        1.        ,  1.        ,  1.        ,  1.        ,  1.        ,
        1.        ,  1.        ,  1.        ,  1.        ,  1.        ,  1.        ])

In [631]:
re


Out[631]:
array([ 1.        ,  0.99166667,  0.99166667,  0.99166667,  0.99166667,
        0.99166667,  0.99166667,  0.99166667,  0.99166667,  0.99166667,
        0.99166667,  0.99166667,  0.99166667,  0.98333333,  0.95833333,
        0.95      ,  0.95      ,  0.93333333,  0.93333333,  0.93333333,
        0.93333333,  0.93333333,  0.93333333,  0.93333333,  0.93333333,
        0.93333333,  0.925     ,  0.925     ,  0.91666667,  0.91666667,
        0.91666667,  0.91666667,  0.91666667,  0.90833333,  0.9       ,
        0.9       ,  0.9       ,  0.9       ,  0.9       ,  0.9       ,
        0.9       ,  0.9       ,  0.9       ,  0.9       ,  0.9       ,
        0.9       ,  0.89166667,  0.89166667,  0.89166667,  0.89166667,
        0.89166667,  0.89166667,  0.89166667,  0.89166667,  0.89166667,
        0.89166667,  0.89166667,  0.89166667,  0.89166667,  0.88333333,
        0.88333333,  0.875     ,  0.875     ,  0.86666667,  0.86666667,
        0.85833333,  0.85      ,  0.84166667,  0.84166667,  0.84166667,
        0.84166667,  0.83333333,  0.825     ,  0.825     ,  0.825     ,
        0.8       ,  0.79166667,  0.78333333,  0.75833333,  0.74166667,
        0.74166667,  0.73333333,  0.73333333,  0.725     ,  0.71666667,
        0.70833333,  0.70833333,  0.7       ,  0.7       ,  0.69166667,
        0.69166667,  0.69166667,  0.68333333,  0.68333333,  0.68333333,
        0.68333333,  0.675     ,  0.6       ,  0.59166667,  0.575     ,
        0.575     ,  0.55833333,  0.55      ,  0.54166667,  0.53333333,
        0.525     ,  0.525     ,  0.525     ,  0.525     ,  0.50833333,
        0.5       ,  0.5       ,  0.48333333,  0.475     ,  0.475     ,
        0.45833333,  0.44166667,  0.44166667,  0.425     ,  0.41666667,
        0.40833333,  0.4       ,  0.38333333,  0.375     ,  0.375     ,
        0.35833333,  0.34166667,  0.33333333,  0.325     ,  0.31666667,
        0.30833333,  0.3       ,  0.29166667,  0.28333333,  0.275     ,
        0.25833333,  0.25      ,  0.24166667,  0.23333333,  0.225     ,
        0.21666667,  0.2       ,  0.19166667,  0.18333333,  0.175     ,
        0.16666667,  0.15833333,  0.14166667,  0.08333333,  0.075     ,
        0.05833333,  0.05      ,  0.03333333,  0.01666667,  0.00833333,  0.        ])

In [632]:
plt.plot(re, pr)
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.show()



In [633]:
from sklearn.metrics import average_precision_score

In [634]:
average_precision_score(y_test, y_scores_lr)


Out[634]:
0.86434051934013389

In [635]:
y_scores_svm = svm.decision_function(X_test)[:,0]
print y_scores_svm


[-0.99981496 -0.99981841 -0.99966013  0.40222691 -0.18327508  0.75939843
  0.9536569  -0.99991568 -0.05034288  0.86014333  0.30132221 -1.00015152
  0.9536569  -1.0000322  -0.60394437  0.99978152 -0.18646874  0.9536569
 -0.61737032 -0.52426426 -1.00009455 -0.19295233 -0.68712759 -0.99966013
 -0.99981496 -1.24454265 -0.32524404 -0.99981841  0.42832029  0.89874226
 -1.0001764  -0.22659992 -0.99971299  0.9536569  -1.22409398 -0.73004156
 -0.55006399  0.9536569   1.00013691 -0.99981496 -0.99984105 -1.05689814
 -0.99981496 -0.99981496 -0.98486017 -0.99991568 -1.0001764  -0.93697004
 -1.00009455 -0.13916673  0.99968615  0.08807267 -1.05123109 -0.31542661
 -0.3003743   0.99960225 -0.91025477  0.14916905  1.00462638 -0.68712759
 -1.09165169  0.64565318  0.99976743 -0.99971299 -0.99981496  0.6008607
 -0.99984105 -1.05689814 -1.16630504  0.08807267  0.28145253  0.99960225
  0.54635734  0.99983341 -0.93697004 -1.00035035  1.00395461  1.0002736
  0.06918607 -1.00047849 -0.99991568  1.12181965  1.0001936  -0.99981496
 -0.19845362 -0.82176644  0.96184789  1.00013691  0.31127995 -0.99981496
 -1.00034439 -1.00003491 -0.99999854 -0.99981496 -0.99981496 -1.00032827
  0.41634089 -1.08909555  0.76004793 -0.73004156 -1.00015445 -1.00015005
  0.86014333 -1.00002206 -1.01163872 -1.17933509  0.21734232 -0.52426426
 -1.0000322  -0.32524404  1.00011438 -1.06812699  1.00011438  0.17002409
 -0.99971299 -0.99966013 -0.82176644 -0.60394437  0.70529212 -0.38710799
 -1.00027009  1.00249805 -0.73153413  1.03189648 -1.17933509  0.11504032
  1.00030148 -0.19748304  0.9536569  -1.09165169  0.9536569  -0.99981496
 -1.00027429  0.99968615  0.27770422 -0.0681501   1.00011438 -1.05689814
 -1.23387029 -0.7359843  -1.09165169  0.19532508 -1.0000815  -0.44087799
 -1.00016118  1.00027991 -1.00411981 -0.32562482  1.00011438 -1.13372474
 -0.99981496 -1.00009455 -1.22409398  0.9536569  -0.99981496 -0.99981496
 -0.99981496  0.9536569   0.76004793  0.7401045  -0.94729974 -0.99971299
 -0.68209835  1.00011438 -0.99981496 -0.73492098 -1.00027009  1.00011438
 -0.99971214 -1.00015005 -0.5911759   0.49521832  0.17002409 -1.00003491
 -1.16630504 -0.99981496 -0.91788366  0.47672326  1.00006423 -0.92714783
 -1.00027009 -0.94422883 -0.99967533  0.1692323  -0.19748304 -0.79860195
 -1.06296833 -0.99981496 -0.99971299 -0.08245382 -1.00035035 -0.99514905
 -1.16630504 -1.05689814  0.43017582  1.13082617  1.00030783 -0.99974364
  1.07927675 -0.69844771 -0.31335693  1.01954543  0.04168266 -0.06344275
 -0.99966013  0.9536569  -1.05689814  0.17002409 -0.99981496 -0.75284661
  0.34044953 -1.0000322   1.00019687 -0.99981496  0.9536569  -0.07665348
  0.18953415 -0.8437192   0.18953415 -0.99981496 -0.99981496  0.99997909
 -1.22409398 -0.99971299 -1.17933509  0.99997909 -0.99971214  0.50085028
  0.99997909  0.09866636 -0.99974364  0.80949828 -0.99981496  0.9536569
 -0.99981496 -0.22659992 -0.63540736 -0.7359843   0.83056586 -0.3067653
 -1.0001764  -0.08245382 -0.99981496 -0.97551768 -1.02395073 -1.00032827
 -0.99981496 -0.93697004 -0.99971214 -0.76546646  1.01954543 -0.51795731
 -0.99981496 -0.99971214 -0.55248177 -0.73004156 -0.99971214 -0.21889438
 -0.60394437  1.12181965  1.0002736  -0.55248177  0.21734232 -0.73004156
 -0.99971299 -0.73492098 -1.16630504 -0.55006399  0.55213909 -0.99981496
  0.74903561 -0.60394437 -1.00224354  0.31127995  1.09785187 -1.05689814
 -1.22409398 -1.00027429  0.99983341 -0.68209835 -0.99967533 -0.99966013
  1.00011438 -0.6532176  -1.00027009  0.61276806  0.9536569  -0.99981496
  1.00009433  0.42832029 -1.0001764  -1.08565214  0.74903561  0.9536569
 -1.09165169 -0.83554648 -0.99981496]

In [636]:
pr_lr, re_lr, _ = precision_recall_curve(y_test, y_scores_lr, pos_label=1)
pr_svm, re_svm, _ = precision_recall_curve(y_test, y_scores_svm, pos_label=1)
plt.plot(re_lr, pr_lr, label='LR')
plt.plot(re_svm, pr_svm, label='SVM')
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.legend()
plt.show()



In [637]:
print average_precision_score(y_test, y_scores_lr)
print average_precision_score(y_test, y_scores_svm)


0.86434051934
0.805608502352

ROC i AUC

  • ROC = Receiver Operating Characteristics
    • TPR kao funkcija od FPR
  • AUC = Area Under the (ROC) Curve

In [540]:
from sklearn.metrics import roc_curve, auc

In [552]:
fpr_lr, tpr_lr, _ = roc_curve(y_test, y_scores_lr)
roc_auc_lr = auc(fpr_lr, tpr_lr)

fpr_svm, tpr_svm, _ = roc_curve(y_test, y_scores_svm)
roc_auc_svm = auc(fpr_svm, tpr_svm)

In [599]:
plt.plot(fpr_lr, tpr_lr, label='LR ROC curve (area = %0.2f)' % roc_auc_lr)
plt.plot(fpr_svm, tpr_svm, label='SVM ROC curve (area = %0.2f)' % roc_auc_svm)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlabel('FPR')
plt.ylabel('TPR')
plt.legend(loc='lower right')
plt.show()


F-mjera

  • F1-mjera: $$ F = \frac{2}{\frac{1}{P}+\frac{1}{R}} = \frac{2PR}{P+R} $$
  • F-beta: $$ F_\beta = \frac{(1+\beta^2)PR}{\beta^2 P +R} $$
  • $F_{0.5}$ dvostruko naglašava preciznost, $F_{2}$ dvostruko naglašava recall

In [555]:
def f_beta(p, r, beta):
    return ((1 + beta**2) * p * r) / (beta**2 * p + r)

In [557]:
f_beta(0.5, 0.9, 1)


Out[557]:
0.6428571428571429

In [560]:
f_beta(0.5, 0.9, 0.5)


Out[560]:
0.5487804878048781

In [561]:
f_beta(0.5, 0.9, 2)


Out[561]:
0.7758620689655172

In [562]:
(0.5 + 0.9) / 2


Out[562]:
0.7

In [563]:
sqrt(0.5 * 0.9)


Out[563]:
0.67082039324993692

In [565]:
2/(1/0.5 + 1/0.9)


Out[565]:
0.6428571428571428

In [578]:
r = 0.5
xs = sp.linspace(0, 1)
plt.plot(xs, (xs + r)/2, label='aritm')
plt.plot(xs, sp.sqrt(xs*r), label='geom')
plt.plot(xs, 2/(1/xs + 1/r), label='harm')
plt.legend(loc='lower right')
plt.show()


Višeklasna klasifikacija


In [669]:
data = sp.loadtxt("path/do/glass.data", delimiter=",", skiprows=1)

In [640]:
print data


[[   1.         1.52101   13.64    ...,    0.         0.         1.     ]
 [   2.         1.51761   13.89    ...,    0.         0.         1.     ]
 [   3.         1.51618   13.53    ...,    0.         0.         1.     ]
 ..., 
 [ 212.         1.52065   14.36    ...,    1.64       0.         7.     ]
 [ 213.         1.51651   14.38    ...,    1.57       0.         7.     ]
 [ 214.         1.51711   14.23    ...,    1.67       0.         7.     ]]

In [670]:
shape(data)


Out[670]:
(214, 11)

In [671]:
glass_X, glass_y = data[:,1:10], data[:,10]

In [672]:
from sklearn import cross_validation
X_train, X_test, y_train, y_test = cross_validation.train_test_split(glass_X, glass_y, train_size=2.0/3, random_state=42)

In [673]:
X_train.shape, X_test.shape


Out[673]:
((142, 9), (72, 9))

In [675]:
from sklearn.svm import SVC

In [676]:
m = SVC() # SVC(C=1, gamma='auto')

In [677]:
m.fit(X_train, y_train)


Out[677]:
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0,
  kernel='rbf', max_iter=-1, probability=False, random_state=None,
  shrinking=True, tol=0.001, verbose=False)

In [678]:
m.classes_


Out[678]:
array([ 1.,  2.,  3.,  5.,  6.,  7.])

In [648]:
y_pred = m.predict(X_test); y_pred


Out[648]:
array([ 2.,  7.,  1.,  7.,  2.,  2.,  1.,  2.,  2.,  1.,  5.,  2.,  1.,
        2.,  1.,  5.,  2.,  1.,  1.,  2.,  1.,  7.,  7.,  7.,  2.,  1.,
        1.,  1.,  5.,  1.,  1.,  2.,  1.,  2.,  1.,  7.,  5.,  1.,  1.,
        2.,  1.,  7.,  1.,  2.,  1.,  5.,  1.,  1.,  1.,  1.,  1.,  1.,
        1.,  2.,  1.,  2.,  7.,  1.,  5.,  1.,  2.,  2.,  1.,  7.,  2.,
        2.,  1.,  2.,  2.,  1.,  2.,  1.])

In [649]:
from sklearn.metrics import confusion_matrix

In [650]:
confusion_matrix(y_test, y_pred)


Out[650]:
array([[19,  4,  0,  0,  0,  0],
       [11, 13,  0,  1,  0,  0],
       [ 3,  1,  0,  0,  0,  0],
       [ 0,  2,  0,  4,  0,  0],
       [ 1,  2,  0,  1,  0,  0],
       [ 0,  1,  0,  0,  0,  9]])

In [651]:
from sklearn.metrics import f1_score

In [667]:
f1_score(y_test, y_pred, pos_label=l, average=None)


Out[667]:
array([ 0.66666667,  0.54166667,  0.        ,  0.66666667,  0.        ,
        0.94736842])

In [668]:
sp.mean(_)


Out[668]:
0.47039473684210531

In [597]:
f1_score(y_test, y_pred, average='macro')


Out[597]:
0.47039473684210531

In [598]:
f1_score(y_test, y_pred, average='micro')


Out[598]:
0.625

Procjena pogreške

TODO

Statističko testiranje

TODO

Usporedba klasifikatora

TODO

Sažetak

TODO