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
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.