'Scikit learn metric giving unexpected error
I run the code below:
from sklearn.metrics import precision_score
y_true = [0, 1, 2, 0, 1, 2]
y_pred = [0, 2, 1, 0, 0, 1]
metrics.precision_score(y_true, y_pred, average='macro')
and I get the error
AttributeError: 'list' object has no attribute 'precision_score'
What is wrong with my code?
Scikit-learn==0.23.2
Solution 1:[1]
Try :
precision_score(y_true, y_pred, average='macro')
Instead of
metrics.precision_score(y_true, y_pred, average='macro')
Maybe you created a variable metrics some where before this code
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | script0 |
