계층을 활용한 데이터 일반화

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

Rebeca Gonzalez

Data engineer

데이터 일반화

데이터 값을 더 덜 구체적인 값으로 바꿉니다.

  • "Dancer" -> "Artist"
  • "Archaeologist" -> "Scientist"
  • "Allergist" -> "Doctor"
Python으로 배우는 데이터 프라이버시와 익명화

계층으로 데이터 일반화

왼쪽에는 직업 목록, 오른쪽에는 상위 일반 카테고리를 보여주는 이미지.

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

난민 상태 데이터셋

# Explore dataset
refugee_df.head()
     Nationality    Gender    RefugeeStatus    Year
0    russian        F         0                2010
1    colombian      M         0                2008
2    vietnamese     F         1                2008
3    korean         M         0                2010
4    ethiopian      F         1                2012
Python으로 배우는 데이터 프라이버시와 익명화

데이터셋 탐색

# Set k value to 4
k = 4


# Calculate how many unique combinations are for nationality and gender df_count = df.groupby(['Nationality', 'Gender']).size().reset_index(name='Count')
# Filter the rows that have a count value less than k df_count[df_count['Count'] < k]
      Nationality   Gender    Count
4     colombian     F         2
7     cuban         M         2
12    liberian      F         2
14    mexican       F         3
15    mexican       M         3
17    russian       M         1
20    ukranian      F         3
21    ukranian      M         1
Python으로 배우는 데이터 프라이버시와 익명화

계층으로 데이터 일반화

# See the combination counts
df['Nationality'].value_counts()
belarusian    14
korean        14
ethiopian     10
chinese       10
vietnamese     9
taiwanese      9
colombian      6
cuban          6
russian        6
mexican        6
liberian       6
ukranian       4
Name: Nationality, dtype: int64
Python으로 배우는 데이터 프라이버시와 익명화

계층으로 데이터 일반화

# Create hierarchies for origin countries
hierarchies = {'Europe': ['ukranian','russian','belarusian'], 
               'America':['mexican','colombian','cuban'],
               'Asia': ['taiwanese','korean','chinese'],
               'Africa': ['ethiopian','liberian']}
Python으로 배우는 데이터 프라이버시와 익명화

계층으로 데이터 일반화

# Creating hierachy father for each contry
origin_hierarchy = {}
for (key, countries) in hierarchies.items():
    for country in countries:
        origin_hierarchy[country] = key

origin_hierarchy
{'belarusian': 'Europe',
 'chinese': 'Asia',
 'colombian': 'America',
 'cuban': 'America',
 'ethiopian': 'Africa',
 'korean': 'Asia',
 'liberian': 'Africa',
 'mexican': 'America',
 'russian': 'Europe',
 'taiwanese': 'Asia',
 'ukranian': 'Europe'}
Python으로 배우는 데이터 프라이버시와 익명화

계층으로 데이터 일반화

# Apply origin_hierarchy hierarchy generalization to Nationality
df['Nationality_generalized'] = df['Nationality'].map(origin_hierarchy)


# Explore resulting dataset df.head()
     Nationality   Gender    RefugeeStatus    Year    Nationality_generalized
0    korean        M         1                2019    Asia
1    ethiopian     M         1                2003    Africa
2    cuban         M         0                2015    America
3    cuban         F         0                2001    America
4    korean        M         0                2013    Asia
Python으로 배우는 데이터 프라이버시와 익명화

계층으로 데이터 일반화

# Calculate how many unique combinations are for Nationality_generalized and Gender
df_count = df.groupby(['Nationality_generalized', 'Gender']).size()
                                                            .reset_index(name='Count')

# Filter the combinations that appear less than k times
df_count[df_count['Count'] < k] 
    Nationality_generalized    Gender    Count
Python으로 배우는 데이터 프라이버시와 익명화

K-익명성 더 알아보기

유형:

  • 제약 기반 접근
  • 몬드리안 다차원 접근
Python으로 배우는 데이터 프라이버시와 익명화

K-익명성은 얼마나 안전한가요?

민감 속성의 다양성이 부족할 때 개인정보 유출이 어떻게 발생할 수 있는지 보여 주는 표. Bob이 표에 있고, 모든 특성을 만족하며, 같은 질병을 가진 k명 그룹에 속하므로 특정 질병을 가졌음을 확실히 알 수 있는 예시.

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

연습해 봅시다!

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

Preparing Video For Download...