library(tidyverse)
library(janitor)
library(scales)
url <- "https://raw.githubusercontent.com/acatlin/data/refs/heads/master/penguin_predictions.csv"
df <- read_csv(
file = url,
show_col_types = FALSE,
progress = FALSE
)Assignment 2B - KCH - Approach
Overview and Introduction
Data is provided in the form of a .csv file. A machine-learning classification model was previously used to generate predictions of the apparent sex of a penguin, ostensibly based on physical features such as height, fin length, color, etc. The feature set required to train the model is not included in the assignment’s files. The main task will be to evaluate the performance of this classification model using several key viewpoints: null error rate, confusion matrices, and performance metrics.
Anticipated challenges include the need to calculate the same metrics for various probability thresholds without a function. This may motivate learning to cast functions or a brute-force approach will be employed.
Data Import
First, the data is loaded from a github-located .csv using read_csv.
Next, the column names are converted to snake_case and the first 10 rows of the data frame are viewed.
clean_df <- janitor::clean_names(df)
head(clean_df,10)# A tibble: 10 × 3
pred_female pred_class sex
<dbl> <chr> <chr>
1 0.992 female female
2 0.954 female female
3 0.985 female female
4 0.187 male female
5 0.995 female female
6 1.000 female female
7 0.959 female female
8 1.000 female female
9 1.000 female female
10 0.339 male female