Skip to content

Commit

Permalink
[Doc] Small fixes (fairlearn#1354)
Browse files Browse the repository at this point in the history
* Add a type hint

* Silence some warnings

* Remove duplicate .bib entry

* More DF fixes

* Update for autogen file

* Get column type right

* Experimenting with some other doc changes

* Undo annotation changes

* blacken
  • Loading branch information
riedgar-ms authored Mar 13, 2024
1 parent fc2979d commit 2aea194
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ instance/
# Sphinx documentation
docs/_build/
docs/auto_examples/
docs/sg_execution_times.rst

# PyBuilder
target/
Expand Down
8 changes: 0 additions & 8 deletions docs/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,3 @@ @misc{sykes2020boston
title={- B 1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town},
url={https://github.com/scikit-learn/scikit-learn/issues/16155}
}

@misc{carlisle2019racist,
author={M Carlisle},
title={racist data destruction?},
publisher={Medium},
year={2019},
url={https://medium.com/@docintangible/racist-data-destruction-113e3eff54a8}
}
2 changes: 1 addition & 1 deletion examples/plot_grid_search_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def classifier(X):
disparity = DemographicParity()
disparity.load_data(X_train, pd.Series(Y_train), sensitive_features=A_train)

errors.append(error.gamma(classifier)[0])
errors.append(error.gamma(classifier).iloc[0])
disparities.append(disparity.gamma(classifier).max())

all_results = pd.DataFrame(
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_intersectional_bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ def intersectionalf(truelabels, predictions):
test["Diagnosis"] = test["Diagnosis"].astype(int)

# Create new intersect column for plotting
test["intersect"] = np.nan
test["intersect"] = ""
test.loc[(test["Sex"] == "Male") & (test["Race"] == "White"), "intersect"] = "WhiteM"
test.loc[(test["Sex"] == "Male") & (test["Race"] == "Black"), "intersect"] = "BlackM"
test.loc[(test["Sex"] == "Male") & (test["Race"] == "Hispanic"), "intersect"] = "HispanicM"
Expand Down
8 changes: 4 additions & 4 deletions fairlearn/metrics/_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ def plot_metric_frame(
for i in range(len(temp_axs[j].patches)):
temp_axs[j].text(
i,
df_all_bounds[metric][i][0] - 0.05 * y_range,
round(df_all_bounds[metric][i][0], ci_labels_precision),
df_all_bounds[metric].iloc[i][0] - 0.05 * y_range,
round(df_all_bounds[metric].iloc[i][0], ci_labels_precision),
fontsize=ci_labels_fontsize,
color=ci_labels_color,
ha=ci_labels_ha,
)
temp_axs[j].text(
i,
df_all_bounds[metric][i][1] + 0.01 * y_range,
round(df_all_bounds[metric][i][1], ci_labels_precision),
df_all_bounds[metric].iloc[i][1] + 0.01 * y_range,
round(df_all_bounds[metric].iloc[i][1], ci_labels_precision),
fontsize=ci_labels_fontsize,
color=ci_labels_color,
ha=ci_labels_ha,
Expand Down
2 changes: 1 addition & 1 deletion fairlearn/reductions/_moments/error_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def load_data(self, X, y, *, sensitive_features, control_features=None):
super().load_data(X, y_train, sensitive_features=sf_train)
self.index = [_ALL]

def gamma(self, predictor):
def gamma(self, predictor) -> pd.Series:
"""Return the gamma values for the given predictor."""
pred = predictor(self.X)
if isinstance(pred, np.ndarray):
Expand Down

0 comments on commit 2aea194

Please sign in to comment.