Mais conteúdo relacionado
Semelhante a [Ankus Open Source Conference 2013] Introduction to Ankus / data mining (20)
[Ankus Open Source Conference 2013] Introduction to Ankus / data mining
- 4. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
빅데이터가 아닌 빅앤서
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
4 / 49
- 5. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
빅데이터 – 시스템(인프라)와 분석
빅데이터 분석
MapReduce 기반의 데이터 분석
SYSTEM / MANAGEMENT
ANALYSIS / APPLICATION
Data Mining and
Machine Learning
/ Statistics and OLAP
Hadoop and Ecosystem
/ MapReduce
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
5 / 49
- 6. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
데이터의 현황 vs. 데이터의 패턴
Data Mining and
Machine Learning
Statistics and OLAP
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
6 / 49
- 7. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
데이터 마이닝
• Description
• 대량의 데이터로부터 그 안에 숨어있는(implicit) 새롭고(previously unknown), 가치 있고(non-
trivial), 의사결정에 유용핚(potentially useful) 정보를 찾는 작업
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
7 / 49
- 8. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
데이터 마이닝 기법의 분류
Classification
(Supervised)
Machine
Learning
Predictive
Clustering
(Unsupervised)
Data Mining
k-NN
Decision Tree
Neural Networks
SVM
Regression
Bayes Network
k-means
EM
Density Based
SOM
Hierarchical
Descriptive
Association
Recommendation
Collaborative Filtering
Contents Based
Association Rule Based
Text Mining
Social Analysis, ….
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
8 / 49
Apriori
FP-Growth
- 9. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
데이터 마이닝 기법의 이해
SNS 영향도 분석
vs.
고객이탈 분석
What Algorithm?
데이터의 특징과 해결하려는 문제에 적합핚
기법(알고리즘)을 선택해야 핚다.
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
9 / 49
- 10. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
분류 및 군집 문제의 예
Classification (분류)
Clustering (군집)
• Supervised Learning (Predictive DM)
• 데이터(레코드)들을 미리 지정된 부류나 등급으
로 나누는 작업
• Unsupervised Learning (Descriptive DM)
• 데이터(레코드)들을 유사핚 성격을 가지는 그룹
으로 분핛하는 작업
• 예) 신용 등급에 따라 고객을
분류 하는 모델을 구축하고,
신규 고객의 정보에 따라 신용 등급을 예측
• 예) 고객을 특징이 유사핚
그룹으로 분핛하고 그룹별
특징을 분석
• 스팸 메일 자동 분류
• 문서의 카테고리 자동 분류
• 인터넷 중독 짂단 시스템
• 학업 성취도/능력에 따른 학생 특징 분석
• 특정 질병에 대핚 유전자 발현 특징 분석
• 구매 패턴 유사 고객 특징 분석
특징(features)/속성(attributes)
목표 클래스 (target class)
ID
월소득
직업
나이
학력
지역
기대출금
연체여부
…
신용등급
1
500
개발
45
대졸
강남
2,000
No
…
A
2
300
영업
30
고졸
은평
0
No
…
B
..
..
..
..
..
..
..
..
..
..
-
350
영업
40
대졸
구로
1,000
No
..
?
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
10 / 49
- 11. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
연관 분석
• Association
• 거래(구매) 데이터에서 자주 함께 판매되는 상품들갂의 연관성에 대핚 규칙을 찾아내는 분석
Walmart
vs.
• 장바구니 분석 (마트 등에서의 구매 상품 목록)
• 금융 상품 구매 분석
• 영화/VOD 등 디지털 콘텐츠 구매 분석
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
11 / 49
- 12. I. 빅데이터 분석과 데이터 마이닝
http://www.openankus.org/
추천 분석
• Recommendation (Personalization)
• 사용자가 좋아핛 만핚 콘텐츠/아이템을 선별해 내어 사용자에게 권유/소비를 유도 하는 것
[ 협력적 추천 – 사용자 기반 ]
나와 선호(시청) 성향이 유사핚 사용자들이 좋다고 핚 아이템(영화)를 나에게 추천핚다.
[ 콘텐츠 내용 기반 추천 ]
내가 과거에 주로 구매(시청)핚 아이템(영화)의 내용 특징에 따라 새로운 영화를 추천핚다.
Amazon, Netflix, MovieLens, Watcha
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
12 / 49
- 14. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
전통적 데이터 분석(마이닝) 도구
WEKA
SAS Enterprise Miner
R
ECMiner
IBM SPSS Modeler
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
14 / 49
- 15. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
Hadoop Ecosystem과 빅데이터 분석 도구
Data Analysis Tool
for Hadoop MapReduce
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
Data Mining / Machine Learning
for Hadoop MapReduce
15 / 49
- 16. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
Why?
Previous Analysis Tools
MapReduce based Analysis Tools
Data Analysis Tool
Data Processing/Extraction
and Analysis Tool
Local: Data Aggregation
Data Mining /
Machine Learning
Data Processing/Extraction
MapReduce Framework
Distributed Big Data System based on Hadoop
………
namenode
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
datanode-1 datanode-2 datanode-3
16 / 49
datanode-n
- 17. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
MapReduce
개념 및 예제.
MapReduce 프로세스
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
17 / 49
- 18. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
MapReduce: 빅데이터 처리를 위핚 분산 프로세스 구조
• In Wikipedia
• MapReduce is a programming model for processing large data sets with a
parallel, distributed algorithm on a cluster.
• A MapReduce program comprises a Map() procedure that performs filtering and sorting and
a Reduce() procedure that performs a summary operation.
• Hadoop으로 대표되는 빅데이터 플랫폼에서의
데이터 처리 프로세스
• Map/Reduce : Key, Value 구조를 기반으
로 하는 데이터 분산 처리 구조
(프레임워크)
• Google에서 2004년 최초 발표
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
18 / 49
- 19. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
MapReduce 프레임워크의 프로세스 예시
Example: Map/Reduce Process for Words Counting in Data File
3개의 Mapper가 분산 처리
4개의 Reducer가 분산 처리
< Map >
라인 단위입력 내용을
Key와 Value로 구분하여 표기
< Reduce >
동일 Key의 Value를
List로 전달받아 일괄 처리
<Mapper>
하나의 데이터 raw를 처리
<Reducer>
동일 key를 가지는
데이터 raw들을 처리
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
19 / 49
- 20. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
MapReduce 프레임워크의 프로세스 예시: Mapper
Data File
Mapper Input from Data File
Mapper
Key (Line Offset)
Value (String)
Mapper – 1
??????
Deer Beer River
Mapper - 2
Deer Beer River
Car Car River
??????
Car Car River
the number of mappers
= the number of lines
Mapper Output for Reducer
Mapper
1
Beer
1
River
1
Car
1
Car
1
River
Mapper - 2
Value
Deer
Mapper – 1
Key
1
Value Processing
: Key Value Setting
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
Mapper
ex) Split Words
Set Word as “Key”
Set 1 as “Value” for count
6 Key-Value Pairs
20 / 49
- 21. II. MapReduce 기반의 데이터 분석
http://www.openankus.org/
MapReduce 프레임워크의 프로세스 예시: Reducer
Reducer Input
Input from Mapper
(6 key-Value Pair)
Reducer
Key
Value (List)
Key
Value
Reducer-1
Beer
{1}
Deer
1
Reducer-2
Car
{1, 1}
Beer
1
Reducer-3
Deer
{1}
River
1
Reducer-4
River
{1, 1}
Car
Sort / Shuffle
Key
Value
1
Beer
1
Car
1
Key
Value
River
1
Car
1
Car
1
Key
Value
Deer
1
Key
Value
River
1
River
1
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
the number of reducers
= the number of distinct keys
Value Processing (Iterative)
: Key Value Writing
Reducer
Reducer Output
ex) Compute Value Sum
Set Key as “Key”
Set Sum as “Value”
Beer 1
Car 2
Deer 1
Result File River 2
21 / 49
- 23. III. ankus 프레임워크
http://www.openankus.org/
ankus 프레임워크의 목적
MapReduce based Data Mining/Machine Learning Library
for Distributed Big Data System based on Hadoop
[ ankus Framework ]
Data Analysis, Knowledge Discovery, Decision Support
based on Data Mining and Machine Learning
MapReduce Framework
Distributed Big Data System based on Hadoop
………
namenode
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
datanode-1 datanode-2 datanode-3
23 / 49
datanode-n
- 24. III. ankus 프레임워크
http://www.openankus.org/
ankus vs. Mahout
• 장점
• 별도의 전처리 없이 입력 파일 사용 가능
• 다양핚 분석을 위핚 속성 선택 분석 수행 지원
• UI 개발 지원을 통핚 워크플로우 기반 분석 수행
• 단점
• 0.1 (연구/개발) 버전으로 핚정된 개수의 알고리즘 제공
- 향후 지속적 분석 기능(알고리즘) 추가 예정
MapReduce based Data Mining / Machine Learning Libraries
• 장점
• 다양핚 종류의 알고리즘 및 안정된 버전 제공 (2008~)
• Sequence 파일을 이용핚 빠른 수행 속도 지원
• 단점
• Sequence 파일 형태의 입력 파일 구성 처리 필요
• 분석 수행시 속성별 선택 기능 미제공
• UI를 포함하지 않은 CLI 중심의 개발 짂행
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
24 / 49
- 25. III. ankus 프레임워크
http://www.openankus.org/
ankus 프레임워크의 구성
[ Open Source ]
MapReduce based Data Mining/Machine Learning Library
User Interface for Workflow based Analysis
Flamingo
Oozie
…….
Visualization
ankus Core Library (ver.0.1)
Recommendation
NLP/SNS Analysis
Classification
Clustering
Association
Statistics
Similarity/Correlation
Preprocessing
MapReduce
Hadoop System - HDFS, HBase
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
25 / 49
- 26. III. ankus 프레임워크
http://www.openankus.org/
ankus Core Library의 주요 제공 기능
Data Preprocessing and Basic Analysis
Preprocessing
Normalization
(Min/Max based)
Statistics
Numeric Statistics
(Distribution)
Nominal Statistics
(Distribution)
Certainty Factor
(Expert System)
Similarity/Correlation
Boolean Data
(3 Measures)
Numeric Data
(5 Measures)
String Data
(2 Measures)
Data Mining / Machine Learning – Classification and Clustering
Classification
ID3 Decision Tree
(Nominal Only)
Clustering
K-Means
EM
Application Service - Recommendation
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
CF based User/Item
Similarity
Contents based
Item Similarity
User based
Recommendation
Recommendation
Item based
Recommendation
26 / 49
- 27. III. ankus 프레임워크
http://www.openankus.org/
ankus 프레임워크: CLI
> hadoop jar ankus-core-0.0.1.jar KMeans
-input /hadoop/input/weka/iris_3class_numeric_1.txt
-maxIteration 1000
-clusterCnt 3
-indexList 0,1,2,3
Mahout에서는
-exceptionIndexList 4
지원하지 않는 옵션
-normalize true
-output /hadoop/output/km_test1
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
27 / 49
- 30. III. ankus 프레임워크
http://www.openankus.org/
ankus Community
Community Wiki
http://www.openankus.org/
Facebook Group/Page
https://www.facebook.com/groups/478048298938975/
https://www.facebook.com/openankus
Source Open
http://sourceforge.net/projects/ankus/
https://github.com/suhyunjeon/ankus
https://mloss.org/software/view/500/
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
30 / 49
- 32. IV. ankus의 분석 알고리즘
http://www.openankus.org/
ankus Core Library 분석 기능
Data Preprocessing and Basic Analysis
Preprocessing
Normalization
(Min/Max based)
Statistics
Numeric Statistics
(Distribution)
Nominal Statistics
(Distribution)
Certainty Factor
(Expert System)
Similarity/Correlation
Boolean Data
(3 Measures)
Numeric Data
(5 Measures)
String Data
(2 Measures)
Mining – Classification and Clustering
Classification
ID3 Decision Tree
(Nominal Only)
Clustering
K-Means
EM
Application Service - Recommendation
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
CF based User/Item
Similarity
Contents based
Item Similarity
User based
Recommendation
Recommendation
Item based
Recommendation
32 / 49
- 33. IV. ankus의 분석 알고리즘
http://www.openankus.org/
1. MapReduce based Classification
예제 – 1.
ID3 의사결정나무 기반의
분류 분석
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
33 / 49
- 34. IV. ankus의 분석 알고리즘
http://www.openankus.org/
1. MapReduce based Classification – 분류 예
날씨에 따른 Play-Tennis 데이터
분류/예측에 사용되는 속성
id
outlook
temperature
humidity
windy
play-tennis
1
sunny
hot
high
FALSE
no
2
sunny
hot
high
TRUE
no
3
overcast
hot
high
FALSE
yes
4
rainy
mild
high
FALSE
yes
5
rainy
cool
normal
FALSE
yes
6
rainy
cool
normal
TRUE
no
7
overcast
cool
normal
TRUE
yes
8
sunny
mild
high
FALSE
no
9
sunny
cool
normal
FALSE
yes
10
rainy
mild
normal
FALSE
yes
11
sunny
mild
normal
TRUE
yes
12
overcast
mild
high
TRUE
yes
13
overcast
hot
normal
FALSE
yes
14
rainy
mild
high
TRUE
no
분류/예측하고자 하는 클래스
날씨에 따른
Play-Tennis 분류/예측 모델
(Decision Tree)
outlook
sunny
(2/3)
humidity
high
(0/3)
“NO”
Leaf Node
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
normal
(2/0)
“YES”
Leaf Node
34 / 49
overcast
(4/0)
“YES”
rainy
(3/2)
windy
Leaf Node
TRUE
(0/2)
FALSE
(3/0)
“NO”
“YES”
Leaf Node
Leaf Node
- 35. IV. ankus의 분석 알고리즘
http://www.openankus.org/
1. MapReduce based Classification – 분류 가지 생성을 위핚 Information Gain 계산
해당 속성을 이용하여 분류된 데이터들의
선택 가능핚 속성들에 대핚 IG(Information Gain) 계산 후
가장 높은 IG를 가지는 속성을 분류 속성으로 선택
Attribute
IG
outlook
0.246
해당 속성을 이용하여 분류된 데이터들의
선택 가능핚 속성들에 대핚
sunny
IG(Information Gain) 계산 후
(2/3)
가장 높은 IG를 가지는 속성을
분류 속성으로 선택
Attribute temperature
IG
0.571
humidity
0.971
windy
0.020
temperature
0.029
humidity
0.152
windy
0.048
outlook
rainy
(3/2)
overcast
(4/0)
해당 속성을 이용하여 분류된 데이터들의
선택 가능핚 속성들에 대핚
IG(Information Gain) 계산 후
가장 높은 IG를 가지는 속성을
분류 속성으로 선택
Attribute temperature
IG
0.020
“YES”
humidity
humidity
0.020
windy
0.971
windy
Leaf Node
high
(0/3)
“NO”
Leaf Node
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
normal
(2/0)
TRUE
(0/2)
“YES”
FALSE
(3/0)
“NO”
Leaf Node
Leaf Node
35 / 49
“YES”
Leaf Node
- 36. IV. ankus의 분석 알고리즘
http://www.openankus.org/
1. MapReduce based Classification –Information Gain 계산의 MR 구현
다음 분류 속성으로 „humidity를 선택
outlook
sunny
(2/3)
분류 속성 선택을 위핚
데이터 추출 및 속성별 IG 계산
id
outlook
temperature
humidity
windy
play-tennis
1
sunny
hot
high
FALSE
no
2
sunny
hot
high
TRUE
no
8
sunny
mild
high
FALSE
sunny
cool
normal
FALSE
yes
11
sunny
mild
normal
TRUE
humidity
0.971
no
9
Attribute temperature
IG
0.571
yes
s1 j ... smj
j 1
s
E ( A)
I ( s1 j ,...,smj )
m
I ( s1 j , s2 j ...,smj )
pij log 2 ( pij )
i 1
IG( A)
Map
I ( s1 j , s2 j ...,smj ) E ( A)
Reduce
sunny, hot, high, FALSE, no
temperature, (hot, no)
humidity, (high, no)
windy (FALSE, no)
sunny, hot, high, TRUE, no
temperature, (hot, no)
humidity, (high, no)
windy (TRUE, no)
sunny, mild, high, FALSE, no
temperature, (mild, no)
humidity, (high, no)
windy (FALSE, no)
temperature, {(hot, no),
(hot, no),
(mild, no),
(cool, yes),
(mild, yes)}
sunny, cool, normal, FALSE, yes
temperature, (cool, yes)
humidity, (normal, yes)
windy (FALSE, yes)
sunny, mild, normal, TRUE, yes
동일 Key로
셔플/정렬
temperature, (mild, yes)
humidity, (normal, yes)
windy (TRUE, yes)
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
v
windy
0.020
36 / 49
0.571
humidity, {(high, no),
(high, no).
(high, no),
(normal, yes),
(normal, yes)}
0.971
windy, {(FALSE, no),
(TRUE, no),
(FALSE, no),
(FALSE, yes),
(TRUE, yes)}
0.020
- 37. IV. ankus의 분석 알고리즘
http://www.openankus.org/
2. MapReduce based Clustering
예제 – 2.
K-Means 기반의 군집 분석
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
37 / 49
- 38. IV. ankus의 분석 알고리즘
http://www.openankus.org/
2. MapReduce based Clustering – K-Means 군집의 개념
• 군집 분석 – 데이터를 속성이 유사핚 데이터들끼리 그룹을 만드는 것
• K-means – 데이터를 가장 가까운 군집에 핛당 시키고, 동일 소속 데이터들의 정보에 따라
군집의 중심을 업데이트 해 가는 과정을 반복하여 군집을 형성 하는 것
(a) 초기 군집 중심 설정
(b) 데이터에 군집 핛당
(c) 군집 중심 업데이트
(c 반복) 군집 중심이
변경되지 않을
때 까지 b와 c
를 반복 수행
군집 중심이 변경
되지 않으면 종료
(b 반복) 데이터에 군집 핛당
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
38 / 49
- 39. IV. ankus의 분석 알고리즘
http://www.openankus.org/
2. MapReduce based Clustering – MapReduce 설계
K-means 군집 프로세스와 MapReduce 변환
1.
군집의 초기 중심을 설정 핚다.
2.
모든 데이터에 대해 다음을 수행 (반복)
- 데이터 자신과 각 군집 중심과의 거리를 측정핚다.
- 가장 가까운 군집 중심에 데이터 자신을 핛당핚다.
3.
모든 군집에 대해 다음을 수행 (반복)
- 군집에 핛당된 모든 데이터의 평균을 계산핚다.
- 계산된 평균을 군집의 중심 정보로 업데이트 핚다.
4.
업데이트 된 군집 중심 정보와 업데이트 이전의 군집 중심을 비교 핚다
- 만약, 군집 중심이 달라졌다면, 다시 2번 과정부터 반복 핚다.
- 만약 군집 중심이 변경되지 않았다면, 군집을 종료 핚다.
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
39 / 49
모든 데이터에 대해
동일 과정 반복 수행
Mapper
각 군집별 데이터를
이용하여 군집별로
수행 Reducer
- 40. IV. ankus의 분석 알고리즘
http://www.openankus.org/
2. MapReduce based Clustering – MapReduce 구현
Map
Reduce
1, 1
1, (1, 1)
1, {(1, 1)}
(1, 1)
2, 2
2, (2, 2)
9, 9
2, (9, 9)
(7, 7)
10, 10
2, (10, 10)
2, {(2, 2),
(9, 9),
(10, 10)}
동일 Key로
셔플/정렬
X
X
MapReduce 반복
Cluster ID
Cluster Info
1
1, 1
2
2, 2
Map
1, (1, 1)
2, 2
1, (2, 2)
9, 9
2, (9, 9)
10, 10
X
1, 1
2, (10, 10)
X
1, {(1, 1),
(2, 2)}
(1.5, 1.5)
2, {(9, 9),
(10, 10)}
(9.5, 9.5)
X
X
X
X
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
Reduce
40 / 49
- 41. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation
예제 – 3.
사용자 기반 협력적 추천을 위핚
사용자갂 상관 관계 계산
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
41 / 49
- 42. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – 협력적 추천 개요
Process - 1
[ 협력적 추천
Users Extraction having Similar Preference
– 사용자 기반 ]
나와 선호(시청) 성향이
유사핚 사용자들이 좋다고
핚 아이템(영화)를 나에게
추천
Process - 2
Recommendation
based on Similar
User‟s Preferences
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
42 / 49
- 43. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – 사용자간 상관 관계
I1
I2
I3
I4
( Ru ,i
Ru )(Rw,i
Rw )
i I
PCC(u, w)
( Ru ,i
Ru ) 2
( Rw,i
U1
i I
U2
Rw ) 2
U2 = {I2=1, I3=-1, I4=-1}
U3
U4
U5
i I
U5 = {I1=1, I2=1, I3=-1}
PCC(U2, U5) = 1
협력적 추천의 핵심
U2와 U5의 pcc가 1 양의 상관 관계
U2의 I4 값이 -1이므로
U5의 I4 값 또핚 -1일 것
PCC (Pearson Correlation Coefficient): 두 벡터간 공통 항목 값의 상관 관계, -1~1사이의 실수
- 1인 경우 두 벡터는 음의 상관관계, 1인 경우 양의 상관관계, 0인 경우 특별핚 관계가 없음
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
43 / 49
- 44. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – 상관 관계 계산과 추천
• Netflix(DVD 대여 회사) 평가 데이터의 PCC 계산 예
• 사용자들이 대여핚 DVD에 대해 1~5점 사이로 평점을 표기핚 데이터
uid
item-1
item-2
item-3
item-4
item-5
item-6
item-7
item-8
u
5
3
1
2
1
4
5
3
w
4
3
2
1
2
5
4
3
( Ru ,i
Ru )(Rw,i
i I
PCC(u, w)
( Ru ,i
Ru ) 2
( Rw,i
i I
PCC(u, w) 0.82
Rw ) 2
i I
서로 동일핚 성향인 정도가 0.82(최대값 1)
uid
item-100
u
5
w
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
Rw )
? 4 or 5
44 / 49
- 45. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – MapReduce 설계
Netflix 데이터 예 (사용자, 영화, 평점)
Alice, Matrix, 5
Alice, Alien, 1
Alice, Inception, 4
Bob, Alien, 2
Bob, Inception, 5
Peter, Matrix, 4
Peter, Alien, 3
Peter, Inception, 2
Matrix
Alice
Alien
Inception
5
1
4
2
5
3
2
Bob
Peter
4
PCC(Alice, Bob) = ?
PCC(Alice, Peter) = ?
PCC(Bob, Peter) = ?
Sequential 프로그래밍이 아닌
Map/Reduce 구조에 기반핚 PCC 계산 로직 설계/개발 필요
2번의 Map/Reduce 작업을 통해 사용자갂의 PCC 계산 가능
• 1단계 Map/Reduce – 동일 영화를 본 사용자 쌍 정보를 추출
• 2단계 Map/Reduce – 사용자 쌍(동일 영화에 대핚 평점 목록)에 대하여 PCC를 계산
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
45 / 49
- 46. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – 1단계 MapReduce
Map
Alice, Matrix, 5
Matrix (Alice, 5)
Alice, Alien, 1
Alien (Alice, 1)
Alice, Inception, 4
Inception (Alice, 4)
Bob, Alien, 2
Alien (Bob, 2)
Bob, Inception, 5
Inception (Bob, 5)
Peter, Matrix, 4
Matrix (Peter, 4)
Peter, Alien, 3
Alien (Peter, 3)
Peter, Inception, 2
Inception (Peter, 2)
Reduce
Matrix {(Alice, 5)
, (Peter, 4)}
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
Alien {(Alice, 1)
, (Bob, 2)
, (Peter, 3)}
(Alice, Bob) (Alien) (1, 2)
(Alice, Peter) (Alien) (1, 3)
(Bob, Peter) (Alien) (2, 3)
Inception {(Alice, 4)
, (Bob, 5)
, (Peter, 2)}
동일 Key로 셔플/정렬
(Alice, Peter) (Matrix) (5, 4)
(Alice, Bob) (Inception) (4, 5)
(Alice, Peter) (Inception) (4, 2)
(Bob, Peter) (Inception) (5, 2)
46 / 49
- 47. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – 2단계 MapReduce
Map
Alice, Peter, Matrix, 5, 4
(Alice, Peter) (5, 4)
Alice, Bob, Alien, 1, 2
(Alice, Bob) (1, 2)
Alice, Peter, Alien, 1, 3
(Alice, Peter) (1, 3)
Bob, Peter, Alien, 2, 3
(Bob, Peter) (2, 3)
Alice, Bob, Inception, 4, 5
(Alice, Bob) (4, 5)
Alice, Peter, Inception, 4, 2
(Alice, Peter) (4, 2)
Bob, Peter, Inception, 5, 2
(Bob, Peter) (5, 2)
( Ru ,i
Ru )(Rw,i
Rw )
i I
PCC(u, w)
( Ru ,i
i I
Ru ) 2
( Rw,i
i I
Reduce
동일 Key로 셔플/정렬
Matrix
Alice
Alien
Inception
5
1
4
2
5
3
(Alice, Peter) (0.24)
(Alice, Bob) {(1, 2)
, (4, 5)}
(Alice, Bob) (1.00)
(Bob, Peter) {(2, 3)
, (5, 2)}
(Bob, Peter) (-1.00)
2
Bob
Peter
(Alice, Peter) {(5, 4)
, (1, 3)
, (4, 2)}
4
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
47 / 49
Rw ) 2
- 48. IV. ankus의 분석 알고리즘
http://www.openankus.org/
3. MapReduce based Recommendation – MapReduce 수행 요약
Alice, Matrix, 5
Alice, Alien, 1
Alice, Inception, 4
Peter, Matrix, 4
Peter, Alien, 3
Peter, Inception, 2
영화를 키로, 사용자와 점수를 추출
Reducer
동일 영화를 함께 본 사용자 점수 쌍을 생성
Mapper
사용자 쌍을 키로, 함께 본 영화의 점수 쌍을 추출
Reducer
Bob, Alien, 2
Bob, Inception, 5
Mapper
동일 사용자 쌍에 대해 함께 본 영화의 점수 쌍을
취합하여 PCC를 계산
PCC(Alice, Bob) = 0.24
PCC(Alice, Peter) = 1.00
PCC(Bob, Peter) = -1.00
Copyright © ONYCOM, INC. 2013, All Rights Reserved.
48 / 49