Histograms with differential privacy
In this exercise, you'll access the Heart Failure Prediction dataset following the differentially private approach. You will generate and analyze private and non-private histograms and compare them.
You'll focus on histograms from the age
variable of the dataset. Although you can access the intact DataFrame in the console, in real life, you wouldn't share it without adding random noise calculated by differential privacy, following the global approach.
The DataFrame is loaded as heart_df
while the Series
holding the values from age
is stored as ages
. tools
from diffprivlib
is already imported.
Cet exercice fait partie du cours
Data Privacy and Anonymization in Python
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Get counts and bars for non-private histogram of ages
counts, bins = ____
# Normalize counts to get proportions
proportions = ____
# Draw the histogram of proportions
plt.bar(____[: - 1], height=____, width=(bins[1] - bins[0]))
plt.show()