ComeçarComece de graça

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.

Este exercício faz parte do curso

Data Privacy and Anonymization in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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()
Editar e executar o código