{"id":18359101,"url":"https://github.com/ev2900/data_science_notes","last_synced_at":"2026-01-31T16:05:46.754Z","repository":{"id":178646861,"uuid":"650650574","full_name":"ev2900/Data_Science_Notes","owner":"ev2900","description":"Handy reference notes for common data sciences topics","archived":false,"fork":false,"pushed_at":"2023-07-04T14:18:28.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T04:40:56.590Z","etag":null,"topics":["accuracy","classification","data-science","f1-score","precision","recall"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ev2900.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-07T14:10:07.000Z","updated_at":"2023-07-03T02:07:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"a436e582-879e-48d1-8b82-88807a8362d8","html_url":"https://github.com/ev2900/Data_Science_Notes","commit_stats":null,"previous_names":["ev2900/data_science_notes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ev2900/Data_Science_Notes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev2900%2FData_Science_Notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev2900%2FData_Science_Notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev2900%2FData_Science_Notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev2900%2FData_Science_Notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ev2900","download_url":"https://codeload.github.com/ev2900/Data_Science_Notes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev2900%2FData_Science_Notes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28947568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accuracy","classification","data-science","f1-score","precision","recall"],"created_at":"2024-11-05T22:20:48.694Z","updated_at":"2026-01-31T16:05:46.718Z","avatar_url":"https://github.com/ev2900.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Key Concepts in Classification Model(s)\n\nThis readme is a place to document key concepts of data science esp. as it pertains to classification models.\n\n## Precision, Accuracy \u0026 Recall\n\nCalculating precision, accuracy and recall requires testing a model with a labeled data set and determining the number of true positives, True negatives, false positives and false negatives. \n\nThe definition of each is below\n* **True positive** an outcome where the model correctly predicts the positive class. A correct prediction \u003cbr\u003e\n* **True negative** an outcome where the model correctly predicts the negative class. A correct prediction \u003cbr\u003e\n* **False positive** an outcome where the model incorrectly predicts the positive class. An incorrect prediction \u003cbr\u003e\n* **False negative** an outcome where the model incorrectly predicts the negative class. An incorrect prediction \u003cbr\u003e\n\n### Precision\n* $\\frac{number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} positives}{number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} positives \\hspace{1mm} + \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} false \\hspace{1mm} positives \\hspace{1mm}}$\n  \n* The best possible precision a model can achieve is 1\n* The worst possible precision a model can achieve is 0\n* If you picture a target with a bullseye - precision is how tight a grouping of shots at the target are\n* Precision can also be thought of as the proportion of positive identifications that were actually correct\n* *Example* if we have a classification model that predicts will it rain or not and the model has a precision of 0.5 (ie. 50%). When the model predicts it will rain it is correct 50% of the time\n* Bear in mind that precision only looks at positives. The formula for precision does not include true or false negatives\n  \n### Accuracy\n* $\\frac{number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} positives \\hspace{1mm} + \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} negatives}{number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} positives \\hspace{1mm} + \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} negatives \\hspace{1mm} + \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} false \\hspace{1mm} positives \\hspace{1mm} + \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} false \\hspace{1mm} negatvies \\hspace{1mm}}$\n* OR $\\frac{number \\hspace{1mm} of \\hspace{1mm} correct \\hspace{1mm} predictions}{total \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} predictions}$\n  \n* The best possible accuracy a model can achieve it 1\n* The worst possible accuracy a model can achieve is 0\n* If you picture a target with a bullseye - accuracy is how close the shots at the target are to the center of the bullseye\n* Accuracy can also be thought of as the proportion of predictions the model got right\n* *Example* if we have a classification model that predicts will it rain or not and the model has a accuracy of 0.5 (ie. 50%). When the model predicts it will rain OR it will not rain it is correct 50% of the time\n* Bear in mind that accuracy can be impacted by data skew or an unbalanced data set. An unbalanced data set is one that has a dispositional amount of a single class. Using our will it rain classification model example - if we have a data set with 10 days of weather history and 9 of the days it did not rain our data set is skewed in the direction of the negative class. Accuracy determined by testing with a skewed data set can resulting in a misleading depiction of accuracy. This reason is why recall is often used instead of accuracy\n\n### Recall\n* $\\frac{number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} positives}{number \\hspace{1mm} of \\hspace{1mm} true \\hspace{1mm} positives \\hspace{1mm} + \\hspace{1mm} number \\hspace{1mm} of \\hspace{1mm} false \\hspace{1mm} negatives}$\n\n* The best possible recall a model can achieve is 1\n* The worst possible recall a model can achieve is 1\n* Recall can be thought of as the proportion correctly classified positive classes among all the real positive classes\n* Using our will it rain classification model example, recall is proportion of times the model predicated it would rain among all the times it actually rained\n\n### Which metric is most important?\n\nUsing our will it rain classification model example\n* Optimize for accuracy when you want to predicting both when it will rain and when it will not rain correctly and our dataset is balanced enough\n* Optimize for precision when you want predictions of when it will rain to be as correct  as possible\n* Optimize for recall when we want our model to spot as many real rainy days as possible\n\n### *Bonus* F1 score\n* $2 * \\frac{Precision \\hspace{1mm} * \\hspace{1mm} Recall}{Precision \\hspace{1mm} + \\hspace{1mm} Recall}$\n\n* The best possible accuracy a model can achieve it 1\n* The worst possible accuracy a model can achieve it 0\n* Combines precision and recall into a single metric by calculating the harmonic mean of precision and recall\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fev2900%2Fdata_science_notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fev2900%2Fdata_science_notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fev2900%2Fdata_science_notes/lists"}