Skip to content

Commit

Permalink
Update setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoGranja authored Dec 30, 2022
1 parent 99018bf commit ece7298
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
pip install -e '.[tests]'
pytest tests
```
### Quick tour
### Quick Tour
Check out the example below to see how EqualityML can be used to assess fairness metrics and mitigate unwanted bias in
the dataset.
Expand All @@ -175,9 +175,11 @@
ml_model.fit(training_data.drop(columns="Y"), training_data["Y"])
# Instantiate a FAIR object
fair_obj = FAIR(ml_model=ml_model, training_data=training_data,
target_variable="Y",
protected_variable="sex", privileged_class=1)
fair_obj = FAIR(ml_model=ml_model,
training_data=training_data,
target_variable="Y",
protected_variable="sex",
privileged_class=1)
# Evaluate a fairness metric (for example statistical parity ratio)
metric_name = 'statistical_parity_ratio'
Expand All @@ -190,14 +192,20 @@
mitigation_method = "resampling"
mitigation_result = fair_obj.bias_mitigation(mitigation_method)
# Noe we can re-train the machine learning model based on mitigated data and
# Now we can re-train the machine learning model based on that mitigated data and
# evaluate again the fairness metric
mitigated_data = mitigation_result['data']
mitigated_data = mitigation_result['training_data']
ml_model.fit(mitigated_data.drop(columns="Y"), mitigated_data["Y"])
fair_obj.update_classifier(ml_model)
new_fairness_metric = fair_obj.fairness_metric(metric_name)
# print the unmitigated fairness metric
print(f"Unmitigated fairness metric = {fairness_metric}")
# print the mitigated fairness metric
print(f"Mitigated fairness metric = {new_fairness_metric}")
# All available fairness metrics and bias mitigation can be printed calling the methods:
fair_obj.print_fairness_metrics()
fair_obj.print_bias_mitigation_methods()
Expand Down

0 comments on commit ece7298

Please sign in to comment.