Page 303 - Ai Book - 10
P. 303

u   F1 Score: F1 score can be defined as the harmonic mean of the Precision and Recall. Thus, the formula is:
                                                              Precision * Recall
                                           F1 Score  =     2 *
                                                              Precision + Recall

             The best value or the perfect value for an F1 score is 1 and the worst value is zero. You should remember
             the following points about precision, recall and F1 score:
              •  If Precision is low and Recall is low, then F1 score is low.
              •  If Precision is low and Recall is high, then F1 score is low.

              •  If Precision is high and Recall is low, then F1 score is low.
              •  If Precision is high and Recall is high, then F1 score is high.
        Now, calculate the accuracy,precision, recall and F1 score for the following scenario:
        Scenario 1: In schools, a lot of times it happens that there is no water to drink. At a few places, cases of water
        shortage in schools are very common and prominent. Hence, an AI model is designed to predict if there is going
        to be a water shortage in the school in the near future or not. The confusion matrix for the same is:


                          The Confusion Matrix             Reality: 1                Reality: 0

                               Predicted: 1                    22                       12

                               Predicted: 0                    47                       18

        Calculate Accuracy, Precision, Recall and F1 Score for the above problem.

                                                  TP                    FP

                                                  22                    12

                                                  47                    18


                                                               (TP + TN)
                                           Accuracy  =                        × 100
                                                           (TP + TN + FP + FN)

                                                                22 + 18
                                                      =                       × 100
                                                           (22 + 18 + 12 + 47)

                                                           40
                                                      =       × 100 = 40.04%
                                                           99

                                                             TP
                                              Recall  =            = .31
                                                           TP + FN

                                                             TP
                                           Precision  =            × 100
                                                           TP + FP

                                                             22
                                                      =            × 100 = 64.70%
                                                           22 + 12
                                                           Precision × Recall
                                           F1 Score  =
                                                           Precision + Recall


                                                                                                             177
                                                                                                             177
   298   299   300   301   302   303   304   305   306   307   308