Ch3_PrecisionScore/Recall_score _ Zero division problem
- Langage dominant
- Jupyter Notebook
- Étoiles
- 30k
- Forks
- 13.1k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I tried running this code:
# If we set a threshold of 70000 based on some precision criteria (say around 90%)
y_train_pred_90 = (y_scores > 70000)
from sklearn.metrics import precision_score, recall_score
print(precision_score(y_train_5, y_train_pred_90))) # output?: 0
#UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division`
parameter to control this behavior.
recall_score(y_train_5, y_train_pred_90) # returning 0
# https://github.com/scikit-learn/scikit-learn/issues/14876#issuecomment-527879372
# https://stackoverflow.com/a/47285662/5114585
I understand that sometimes denominator becomes zero and we get these warnings & we can set default value to be 0 or 1 [https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_score.html]
My questions:
1. My results are not matching from the book [below results from book].
>>> precision_score(y_train_5, y_train_pred_90)
0.8998702983138781
>>> recall_score(y_train_5, y_train_pred_90)
0.63991883416343853
2. Better ways to handle this issue?
Setting different threshold, ignoring the labels which were not predicted [https://stackoverflow.com/a/47285662/5114585](url)
something else?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.