Curvingo · Made in India

Glossary

Select one of the keywords on the left…

Precision and RecallCode with Python

Reading time: ~5 min

scikit-learn has a function for every score in this chapter. Suppose the camp's results are saved in a file, dengue_camp.csv, with one row per person: the test score, and whether the lab found dengue (1) or not (0). Comparing each score with the threshold gives the test's answers, y_pred.

Look closely at the printed matrix: scikit-learn puts the negatives first, so its top row is the healthy people (TN, FP) and its bottom row the patients (FN, TP). Run the program, then try another threshold.

Counting by Hand

Without a library, the four boxes are just four counters. Here are 12 people from the camp. For each person the loop asks two questions — did the test say positive, and did they really have dengue? — and adds 1 to the right box. Run it, then change the threshold.

To reveal more content, you have to complete all the activities and exercises above. 
Are you stuck? or reveal all steps

Next up:
Summary
Sina