From 3c48214cc24353fadf615d7f567912d345b1278b Mon Sep 17 00:00:00 2001 From: federicapicogna <128388440+federicapicogna@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:55:15 +0100 Subject: [PATCH] matrix going back --- R/model_fairness.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/model_fairness.R b/R/model_fairness.R index 0f22fc36..9c801562 100644 --- a/R/model_fairness.R +++ b/R/model_fairness.R @@ -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"]])