diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 18cb668..025194c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -35,15 +35,11 @@ jobs: - {os: windows-latest, r: '4.1'} - {os: windows-latest, r: '4.0'} - {os: windows-latest, r: '3.6'} - - {os: windows-latest, r: '3.5'} - {os: macOS-latest, r: '4.1'} - {os: macOS-latest, r: '4.0'} - - {os: macOS-latest, r: '3.6'} - {os: ubuntu-18.04, r: '4.1', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - {os: ubuntu-18.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - {os: ubuntu-18.04, r: '3.6', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: '3.5', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true diff --git a/DESCRIPTION b/DESCRIPTION index 4d30e37..b7f3326 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: fairmodels Type: Package Title: Flexible Tool for Bias Detection, Visualization, and Mitigation -Version: 1.2.1 +Version: 1.2.2 Authors@R: c(person("Jakub", "Wiśniewski", role = c("aut", "cre"), email = "jakwisn@gmail.com"), @@ -28,7 +28,7 @@ Suggests: spelling, ggdendro, ggrepel, -RoxygenNote: 7.1.1.9001 +RoxygenNote: 7.3.3 VignetteBuilder: knitr URL: https://fairmodels.drwhy.ai/ BugReports: https://github.com/ModelOriented/fairmodels/issues diff --git a/NEWS.md b/NEWS.md index 0f6b162..e4d5d11 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# fairmodels 1.2.2 +* changed ifelse to if else statement in `fairness_heatmap` as per https://github.com/ModelOriented/fairmodels/issues/57 + # fairmodels 1.2.1 * changed link to *codecov* in `README.md` * changed `class(x) == 'fairness_regression_object` to `inherits(x, "fairness_regression_object")` in `plot_density.R` according to CRAN comments diff --git a/R/plot_fairness_heatmap.R b/R/plot_fairness_heatmap.R index f80250f..a2b750f 100644 --- a/R/plot_fairness_heatmap.R +++ b/R/plot_fairness_heatmap.R @@ -14,7 +14,7 @@ #' @param flip_axis logical, whether to change axis with metrics on axis with models #' @param text_size numeric, size of text #' -#' @return list of \code{ggplot2} objects +#' @return ggplot object with the combined heatmap and dendograms #' #' @import patchwork #' @import ggplot2 @@ -166,10 +166,12 @@ plot.fairness_heatmap <- function(x, ..., data$score <- as.numeric(data$score) # heatmap - ifelse(!flip_axis, - p <- ggplot(data, aes(parity_loss_metric, model, fill = score)), + if(!flip_axis) { + p <- ggplot(data, aes(parity_loss_metric, model, fill = score)) + + } else { p <- ggplot(data, aes(model, parity_loss_metric, fill = score)) - ) + } heatmap <- p + geom_tile( colour = "white", @@ -199,15 +201,17 @@ plot.fairness_heatmap <- function(x, ..., ) } - ifelse(!flip_axis, - dendogram_right <- dendogram_model + coord_flip(), + if (!flip_axis) { + dendogram_right <- dendogram_model + coord_flip() + } else { dendogram_right <- dendogram_metric + coord_flip() - ) + } - ifelse(!flip_axis, - dendogram_top <- dendogram_metric, + if (!flip_axis) { + dendogram_top <- dendogram_metric + } else { dendogram_top <- dendogram_model - ) + } # adding title dendogram_top <- dendogram_top + @@ -216,11 +220,13 @@ plot.fairness_heatmap <- function(x, ..., ) # Plot layout - dendogram_top + plot_spacer() + + final_plot <- (dendogram_top + plot_spacer() + heatmap + dendogram_right + patchwork::plot_layout( ncol = 2, widths = c(1, 0.4), heights = c(0.4, 1) - ) + )) + + return(final_plot) }