Skip to content

Commit

Permalink
matrix going back
Browse files Browse the repository at this point in the history
  • Loading branch information
federicapicogna committed Dec 17, 2024
1 parent 520d38e commit 3c48214
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/model_fairness.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ model_fairness <- function(data,
group <- levels(data[, protected])[i]
groupDat <- data[data[, protected] == group, ]
# Confusion matrices for each group
confmat[[group]][["matrix"]] <- table("Predicted" = groupDat[, predictions], "Actual" = groupDat[, target])
confmat[[group]][["matrix"]] <- table("Actual" = groupDat[, target], "Predicted" = groupDat[, predictions])
confmat[[group]][["tp"]] <- tp <- confmat[[group]][["matrix"]][positive, positive]
confmat[[group]][["fp"]] <- fp <- sum(confmat[[group]][["matrix"]][positive, negative])
confmat[[group]][["fp"]] <- fp <- sum(confmat[[group]][["matrix"]][negative, positive])
confmat[[group]][["tn"]] <- tn <- sum(confmat[[group]][["matrix"]][negative, negative])
confmat[[group]][["fn"]] <- fn <- sum(confmat[[group]][["matrix"]][negative, positive])
confmat[[group]][["fn"]] <- fn <- sum(confmat[[group]][["matrix"]][positive, negative])
confmat[[group]][["n"]] <- sum(confmat[[group]][["matrix"]])
# Performance measures for each group
performance[[group]][["support"]] <- performance[["all"]][i, 1] <- sum(confmat[[group]][["matrix"]])
Expand Down

0 comments on commit 3c48214

Please sign in to comment.