Introduction/Approach
For this assignment part 2b, I will use the penguin_predictions.csv data to check how well the model works.
First, I will look at the sex column and count each class. Then, I will make a bar chart to show the class distribution, and will calculate the null error rate to get a baseline for the model.
Furthermore, I will use .pred_female to make predictions. I will also test three thresholds: 0.2, 0.5, and 0.8.
For each threshold, I will create a confusion matrix and will find True Positives, False Positives, True Negatives, and False Negatives.
Moreover, I will calculate accuracy, precision, recall, and F1 score for each threshold and compare the results.
Finally, I will explain how changing the threshold changes the model results and provide examples of when a low or high threshold can be useful.
GitHub links:
https://raw.githubusercontent.com/acatlin/data/refs/heads/master/penguin_predictions.csv
https://github.com/acatlin/data/blob/master/Performance%20Metrics%20for%20Classification%20problems%20in%20Machine%20Learning.pdf
Conclusion
Overall, I tested thresholds 0.2, 0.5, and 0.8. The results changed when I was changing the threshold. At threshold 0.2, recall was the highest, model found more of positive predicted. At the same time, it also had larger number of false positives as well. In its turn, with 0.8 threshold, the model had fewer false positives and had the highest accuracy, precision, and F1 score. Therefore, may be concluded that changing the threshold affects the performance of the model.
Thus, lower threshold more positives predicted , and lower threshold can be useful when it is important not to miss positive cases. In its turn, 0.8 threshold ca be beneficial when is required to reduce false positives.
Baseline Comparison: The null error rate is 41.94%, meaning the baseline accuracy is 58.06%. This means that always predicting the most common penguin class would be right 58.06% of the time. The model performs much better than this baseline. For instance, with 0.8 threshold, the model will be accurate 94.62%. Therefore, the classification model does better than simply predicting the most common class.
References
Google Deep Mind. (2025). Gemini 3 Flash [Large language model]. [https://gemini.google.com.](https://gemini.google.com/) Accessed September 13th, 2026.
Wickham, H., Çetinkaya-Rundel, M., & Grolemund, G. (2023). R for data science (2nd ed.). O’Reilly Media. https://r4ds.hadley.nz/