Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#use helper functions (DPandEO) to calculate the values of DP and EO for - GENDER
```{r, eval=FALSE}
# Read the file with machine learning and GPT outcomes.
#MLresult <- readRDS("~/LLM_Fairness_Fall_2023/StudentNotebooks/Assignment07/german_MLresult.rds")
#print(MLresult) #wG&A1c
# calculate DP and EO for lda
df_lda <- get_subgroup_measures(MLresult$actualResult,
MLresult$LDA_result, german_800$Gender)
DP_lda <- demographic_parity_difference(df_lda)
EO_lda <- equalized_odds_difference(df_lda)
# calculate DP and EO for xgboost
df_xgboost <- get_subgroup_measures(MLresult$actualResult,
MLresult$XGBoost_result, german_800$Gender)
DP_xgboost <- demographic_parity_difference(df_xgboost)
EO_xgboost <- equalized_odds_difference(df_xgboost)
# calculate DP and EO for logistic regression
df_lr <- get_subgroup_measures(MLresult$actualResult,
MLresult$LR_result, german_800$Gender)
DP_lr <- demographic_parity_difference(df_lr)
EO_lr <- equalized_odds_difference(df_lr)
# calculate DP and EO for naive bayes
df_nb <- get_subgroup_measures(MLresult$actualResult,
MLresult$NB_result, german_800$Gender)
DP_nb <- demographic_parity_difference(df_nb)
EO_nb <- equalized_odds_difference(df_nb)
# calculate DP and EO for gpt model
df_gpt <- get_subgroup_measures(MLresult$actualResult,
german_800$predictResult, german_800$Gender)
DP_gpt <- demographic_parity_difference(df_gpt)
EO_gpt <- equalized_odds_difference(df_gpt)
DPEO_df_german <- data.frame(LDA = c(DP_lda, EO_lda),
row.names = c('Demographic Parity Difference (DP)',
'Equalized Odds (EO)'))
DPEO_df_nhanes$XGboost <- c(DP_xgboost, EO_xgboost)
DPEO_df_nhanes$lr <- c(DP_lr, EO_lr)
#DPEO_df_nhanes$rf <- c(DP_rf, EO_rf)
DPEO_df_nhanes$nb <- c(DP_nb, EO_nb)
DPEO_df_nhanes$gpt <- c(DP_gpt, EO_gpt)
saveRDS(DPEO_df_nhanes, "~/LLM_Fairness_Fall_2023/StudentNotebooks/Assignment07/DPEO_df_nhanes_Gender.rds")
```