차등 프라이버시 머신 러닝 모델

Python으로 배우는 데이터 프라이버시와 익명화

Rebeca Gonzalez

Data Engineer

안전한 데이터 공유

유사한 데이터를 가진 기업들이 정보를 공유해 제품과 서비스를 개선합니다.
  • 머신 러닝(ML) 모델 포함

데이터 차트를 보는 사람 이미지

Python으로 배우는 데이터 프라이버시와 익명화

차등 프라이버시 머신 러닝 모델

  • 여러 온라인 상점 파트너가 있는 SaaS 기업
  • 새 파트너는 충분한 데이터 확보까지 수개월 소요 가능
  • DP로 파트너 간 데이터 공유를 장려 가능

화면에서 로켓이 나오는 노트북을 든 남성 그림

$$ $$ 여러 파트너를 나타내는 아이콘 아래에 사람이 있는 그림

Python으로 배우는 데이터 프라이버시와 익명화

머신 러닝과 프라이버시

  • 데이터셋에는 민감 정보가 포함됨
  • 적대자가 ML 알고리즘 출력을 악용할 수 있음
Python으로 배우는 데이터 프라이버시와 익명화

머신 러닝과 프라이버시

차등 프라이버시 머신 러닝 모델

  • 해당 데이터 분포를 따름
  • 개인 프라이버시를 보장 가능
Python으로 배우는 데이터 프라이버시와 익명화

차등 프라이버시 분류 모델

# scikit-learn 나이브 베이즈 분류기 임포트
from sklearn.naive_bayes import GaussianNB


# 차등 프라이버시 나이브 베이즈 분류기 임포트 from diffprivlib.models import GaussianNB
Python으로 배우는 데이터 프라이버시와 익명화

비프라이빗 분류기

from sklearn.naive_bayes import GaussianNB

# 비프라이빗 분류기 생성 nonprivate_clf = GaussianNB()
# 모델 학습 nonprivate_clf.fit(X_train, y_train)
print("The accuracy of the non-private model is ", nonprivate_clf.score(X_test, y_test))
The accuracy of the non-private model is  0.8333333333333334
Python으로 배우는 데이터 프라이버시와 익명화

차등 프라이버시 분류기

from diffprivlib.models import GaussianNB as dp_GaussianNB

# 기본 설정으로 프라이빗 분류기 생성 private_clf = dp_GaussianNB()
# 모델 학습 및 점수 확인 private_clf.fit(X_train, y_train)
print("The accuracy of the private model is ", private_clf.score(X_test, y_test))
The accuracy of the private model is  0.7
PrivacyLeakWarning: Bounds have not been specified and will be calculated 
  on the data provided. This will result in additional privacy leakage.
  To ensure differential privacy and no additional privacy leakage, specify bounds for each dimension.
  "privacy leakage, specify bounds for each dimension.", PrivacyLeakWarning)
Python으로 배우는 데이터 프라이버시와 익명화

프라이버시 누출 방지

데이터 누출을 막으려면 bounds 인자를 전달해 min/max를 지정합니다. 가능한 형태:

  • (min, max) 튜플
    • 전체 데이터의 최소/최대 범위를 덮는 정수
      • 예:
        (0,100)
        
    • 각 열의 최소/최대값 배열
      • 예:
        ([0,1,0,2],[10,80,5,70])
        
Python으로 배우는 데이터 프라이버시와 익명화

프라이버시 누출 방지

# 최소/최대값을 덮도록 bounds 설정 
bounds = (X_train.min(axis=0) - 1, X_train.max(axis=0) + 1)

# epsilon=0.5로 분류기 생성 dp_clf = dp_GaussianNB(epsilon=0.5, bounds=bounds)
# 모델 학습 및 점수 확인 dp_clf.fit(X_train, y_train) print("The accuracy of the private model is ", private_clf.score(X_test, y_test))
The accuracy of the private model is  0.807000
Python으로 배우는 데이터 프라이버시와 익명화

bounds 추가 더 알아보기

# random 모듈 임포트
import random
# bounds의 최소/최대에 노이즈를 추가해 설정
bounds = (X_train.min(axis=0) - random.sample(range(0, 30), 12), 
          X_train.max(axis=0) + random.sample(range(0, 30), 12))


# epsilon=0.5로 분류기 생성 dp_clf = dp_GaussianNB(epsilon=0.5, bounds=bounds)
# 모델 학습 및 점수 확인 dp_clf.fit(X_train, y_train) print("The accuracy of private classifier with bounds is ", dp_clf.score(X_test, y_test))
The accuracy of private classifier with bounds is 0.7544444444
Python으로 배우는 데이터 프라이버시와 익명화

서로 다른 epsilon 값

서로 다른 epsilon 값에 따른 정확도 비교 플롯

Python으로 배우는 데이터 프라이버시와 익명화

프라이버시 보존 모델을 만들어 봅시다!

Python으로 배우는 데이터 프라이버시와 익명화

Preparing Video For Download...