Data Science Cheat Sheet
From IT Wiki
Revision as of 14:12, 4 November 2024 by 핵톤 (talk | contribs) (Created page with "== Confusion Matrix and F1 Score == '''Confusion Matrix''' {| class="wikitable" |- ! !!Predicted Positive!!Predicted Negative |- |'''Actual Positive'''||True Positive (TP)||False Negative (FN) |- |'''Actual Negative'''||False Positive (FP)||True Negative (TN) |} '''F1 Score''' = 2 * (Precision * Recall) / (Precision + Recall) * 2 * (Positive Predictive Value * True Positive Rate) / (Positive Predictive Value + True Positive Rate) * 2 * (TP) / (TP + FP + FN) ==...")
Confusion Matrix and F1 Score
Predicted Positive | Predicted Negative | |
---|---|---|
Actual Positive | True Positive (TP) | False Negative (FN) |
Actual Negative | False Positive (FP) | True Negative (TN) |
F1 Score = 2 * (Precision * Recall) / (Precision + Recall)
- 2 * (Positive Predictive Value * True Positive Rate) / (Positive Predictive Value + True Positive Rate)
- 2 * (TP) / (TP + FP + FN)
Key Evaluation Metrics
True Positive Rate (TPR), Sensitivity, Recall
- TPR = Sensitivity = Recall = TP / (TP + FN)
Precision (Positive Predictive Value)
- Precision = TP / (TP + FP)
Specificity (True Negative Rate, TNR)
- Specificity = TNR = TN / (TN + FP)
- FPR = FP / (FP + TN)
Negative Predictive Value (NPV)
- NPV = TN / (TN + FN)
- Accuracy = (TP + TN) / (TP + TN + FP + FN)
Relationships between Key Concepts
TPR (Recall) and Precision:
- TPR represents the proportion of actual positives correctly predicted by the model, while Precision shows the proportion of predicted positives that are actually positive.
- Increasing TPR (Recall) can sometimes reduce Precision, and vice versa.
FPR and Specificity:
- Specificity = (1 - FPR). In an ROC curve, FPR is plotted on the x-axis and TPR on the y-axis to visualize model performance.
F1 Score:
- Defined as the harmonic mean of Precision and Recall, emphasizing their balance. F1 Score = 2 * (Precision * Recall) / (Precision + Recall)
Accuracy:
- Accuracy reflects the overall model performance but may not be suitable in cases of class imbalance.