why does scikitlearn says F1 score is ill-defined with FN bigger than 0?

后端 未结 2 1375
孤独总比滥情好
孤独总比滥情好 2020-12-08 04:19

I run a python program that calls sklearn.metrics\'s methods to calculate precision and F1 score. Here is the output when there is no predicted sample:

2条回答
  •  [愿得一人]
    2020-12-08 05:06

    Precision, Recall, F1-score and Accuracy calculation

    - In a given image of Dogs and Cats
    
      * Total Dogs - 12  D = 12
      * Total Cats - 8   C = 8
    
    - Computer program predicts
    
      * Dogs - 8  
        5 are actually Dogs   T.P = 5
        3 are not             F.P = 3    
      * Cats - 12
        6 are actually Cats   T.N = 6 
        6 are not             F.N = 6
    
    - Calculation
    
      * Precision = T.P / (T.P + F.P) => 5 / (5 + 3)
      * Recall    = T.P / D           => 5 / 12
    
      * F1 = 2 * (Precision * Recall) / (Precision + Recall)
      * F1 = 0.5
    
      * Accuracy = T.P + T.N / P + N
      * Accuracy = 0.55
    

    Wikipedia reference

提交回复
热议问题