开始使用免费开始使用

使用隐私预算记账器探索数据

提供差分隐私的数据探索系统必须管理隐私预算,用于衡量多次查询所累积的隐私损失。

在本练习中,您将探索 IBM HR Analytics Employee Attrition & Performance 数据集,同时跟踪我们的隐私预算。请记住,如果某个查询超出记账器中指定的隐私预算,就会触发错误。

直方图是以差分隐私方式可视化数据的有用工具。其语法与 numpy 中对应函数相同,但增加了一个 epsilon 参数。

完整数据集已作为 hr 提供,员工的年龄属性为 ages。我们还加载了一个自定义函数 show_histogram(),用于像您在课程前面所做的那样绘制直方图。

本练习是课程的一部分

Python 中的数据隐私与匿名化

查看课程

练习说明

  • 使用其构造函数创建一个隐私 BudgetAccountantepsilon 设为 1.5
  • 基于 ages 列生成一个私有直方图,epsilon0.1
  • 获取并显示 ages 的私有平均值,epsilon0.9,并使用从 10100 的区间作为元组 bounds。
  • 打印以下两个新查询的剩余隐私预算。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Create the privacy Budget Accountant with epsilon of 1.5
acc = ____

# Use the Budget Accountant acc to draw a private histogram of ages with epsilon 0.1
dp_hist, dp_bins = tools.___(____, epsilon=____, range=[10,100], accountant=____)
show_histogram(dp_hist, dp_bins)

# Get and show the private average of the age variable
print("Mean: ", tools.mean(____))

# Show privacy budget remaining for 2 queries
print("Remaining budget for 2 queries: ", ____)
print("Number of queries recorded: ", len(acc))
编辑并运行代码