ageron / ageron/handson-ml2

Ch3_PrecisionScore/Recall_score _ Zero division problem

Aberta
#257 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Jupyter Notebook
Estrelas
30k
Forks
13.1k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.