View source: R/fairness_prediction_density.R
fairness_prediction_density | R Documentation |
Visualizes per-subgroup densities across learners, task and class. The plot is a combination of boxplot and violin plot. The y-axis shows the levels in protected columns. And the x-axis shows the predicted probability. The title for the plot will demonstrate which class for predicted probability.
fairness_prediction_density(object, ...)
object |
(PredictionClassif | ResampleResult | BenchmarkResult) |
... |
The arguments to be passed to methods, such as:
|
A 'ggplot2' object.
The protected attribute is specified as a col_role
in the corresponding Task()
:
<Task>$col_roles$pta = "name_of_attribute"
This also allows specifying more than one protected attribute,
in which case fairness will be considered on the level of intersecting groups defined by all columns
selected as a predicted attribute.
library("mlr3")
library("mlr3learners")
task = tsk("adult_train")$filter(1:500)
learner = lrn("classif.rpart", predict_type = "prob", cp = 0.001)
learner$train(task)
# For prediction
predictions = learner$predict(task)
fairness_prediction_density(predictions, task)
# For resampling
rr = resample(task, learner, rsmp("cv"))
fairness_prediction_density(rr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.