Created
March 1, 2022 19:59
-
-
Save joaopedro-fg/87874b394827df35092da21f677e90ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fairml import audit_model | |
| from fairml import plot_dependencies | |
| from sklearn.linear_model import LogisticRegression | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import pandas as pd | |
| propublica_data = pd.read_csv("./propublica_data_for_fairml.csv") | |
| compas_rating = propublica_data.score_factor.values | |
| propublica_data = propublica_data.drop("score_factor", 1) | |
| clf = LogisticRegression(penalty='l2', C=0.01) | |
| clf.fit(propublica_data.values, compas_rating) | |
| importances, _ = audit_model( clf.predict, propublica_data) | |
| plot_dependencies( | |
| importances.median(), | |
| reverse_values=False, | |
| title="Vieses" | |
| ) | |
| file_name = "fairml_propublica_linear_direct.png" | |
| plt.savefig(file_name, transparent=False, bbox_inches='tight', dpi=250) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment