Seite 1 von 1

Irgendwas stimmt nicht mit dem accuracy_score

Verfasst: Sonntag 16. September 2018, 15:05
von naheliegend
Hi, irgendwas stimmt mit dem accuracy_score nicht. Ich finde den Fehler nicht.

Code: Alles auswählen

from sklearn.metrics import accuracy_score

test_y = 
[[ 5.]
 [32.]
 [50.]]
 
 predi =
 [[2]
 [8]
 [8]]
 
 print("Accuracy:", accuracy_score(test_y, predi))
 
 >>> Out: Accuracy: 0.0 
0.0 kann aber wirklich nicht das Ergebnis sein.
Habe test_y.ravel() und predi.ravel() ausprobiert, was nichts ändert.



Doku:
Accuracy classification score.
In multilabel classification, this function computes subset accuracy: the set of labels predicted for a sample must exactly match the corresponding set of labels in y_true.

Parameters:
y_true : 1d array-like, or label indicator array / sparse matrix
Ground truth (correct) labels.

y_pred : 1d array-like, or label indicator array / sparse matrix
Predicted labels, as returned by a classifier.

normalize : bool, optional (default=True)
If False, return the number of correctly classified samples. Otherwise, return the fraction of correctly classified samples.
sample_weight : array-like of shape = [n_samples], optional
Sample weights.

Returns:
score : float
If normalize == True, return the correctly classified samples (float), else it returns the number of correctly classified samples (int).
The best performance is 1 with normalize == True and the number of samples with normalize == False.

Re: Irgendwas stimmt nicht mit dem accuracy_score

Verfasst: Sonntag 16. September 2018, 17:08
von ThomasL
Welche Accuracy erwartest du denn wenn keine deiner prediction Werte mit dem Truth-Wert übereinstimmt?
Null Übereinstimmung = 0.0 Accuracy
mach doch mal vor dem print() test_y = predi

Re: Irgendwas stimmt nicht mit dem accuracy_score

Verfasst: Sonntag 16. September 2018, 21:33
von naheliegend
ThomasL hat geschrieben: Sonntag 16. September 2018, 17:08 Welche Accuracy erwartest du denn wenn keine deiner prediction Werte mit dem Truth-Wert übereinstimmt?
Null Übereinstimmung = 0.0 Accuracy
mach doch mal vor dem print() test_y = predi
Ah okey, ich verwechsele dann die Accuracy mit dem Bestimmtheitsmaß.