Irgendwas stimmt nicht mit dem accuracy_score

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
naheliegend
User
Beiträge: 439
Registriert: Mittwoch 8. August 2018, 16:42

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.
__backjack__: "Jemand der VB oder PHP kann, der also was Programmieren angeht irgendwo im negativen Bereich liegt (...)"
Benutzeravatar
ThomasL
User
Beiträge: 1366
Registriert: Montag 14. Mai 2018, 14:44
Wohnort: Kreis Unna NRW

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
Ich bin Pazifist und greife niemanden an, auch nicht mit Worten.
Für alle meine Code Beispiele gilt: "There is always a better way."
https://projecteuler.net/profile/Brotherluii.png
naheliegend
User
Beiträge: 439
Registriert: Mittwoch 8. August 2018, 16:42

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ß.
__backjack__: "Jemand der VB oder PHP kann, der also was Programmieren angeht irgendwo im negativen Bereich liegt (...)"
Antworten