開始使用免費開始

使用隱私預算會計器探索資料

提供差分隱私的資料探索系統,必須管理隱私預算,用來衡量多個查詢累積造成的隱私損失。

在這個練習中,你將在追蹤隱私預算的同時,探索 IBM HR Analytics Employee Attrition & Performance 資料集。請記住,如果某個查詢超過會計器中設定的隱私預算,就會產生錯誤。

直方圖是以差分隱私方式視覺化資料的實用工具。語法與 numpy 中對應的函式相同,但多了一個 epsilon 參數。

完整資料集已載入為 hr,員工的年齡欄位為 ages。已建立並載入自訂函式 show_histogram(),可用來繪製直方圖,就像你先前在課程中所做的一樣。

本練習屬於課程

Data Privacy and Anonymization in Python

檢視課程

練習說明

  • 使用其建構子建立一個隱私 BudgetAccountant,並將 epsilon 設為 1.5
  • ages 欄位產生私人直方圖,並將 epsilon 設為 0.1
  • 取得並顯示 ages 的私人平均數,epsilon 設為 0.9bounds 設為從 10100 的 tuple。
  • 列印接下來兩個新查詢可用的剩餘隱私預算。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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))
編輯並執行程式碼