Note
Go to the end to download the full example code
Value counts#
from fairlearn.datasets import fetch_diabetes_hospital
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
data = fetch_diabetes_hospital(as_frame=True)
X = data.data
X.drop(columns=["readmitted", "readmit_binary"], inplace=True)
y_true = data.target
race = X['race']
df = race.value_counts().reset_index()
ax.bar(df["race"], df["count"])
ax.set_title('Counts by race')
ax.tick_params(axis='x', labelrotation=45)
plt.tight_layout()
plt.show()
/home/circleci/tmp-fairlearn/examples/plot_quickstart_counts.py:18: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
X.drop(columns=["readmitted", "readmit_binary"], inplace=True)
Total running time of the script: (0 minutes 3.394 seconds)