Spark Day 2017@Seoul - Spark Summit 2017 ML Best 3

Preview:

Citation preview

이동진 (dongjin.lee@alcacruz.com /

dongjin@apache.org)

Spark Summit 2017

ML Best 3

About the Speaker…

• Apache Committer

• Alcacruz.com

– Senior Software Engineer

– VR Startup, Bay Area

– Machine Learning을 활용한 작업 효율화, 최적화

Outline

• Spark Summit 2017 ML 세션 요약 소개

1. Redis with Apache Spark (by Redis Labs)

2. Automated Machine Learning (by Salesforce)

3. Extending Spark Machine Learning (by IBM)

Redis with Apache Spark

SparkTraining

Redis-ML

(Other System)

ServiceClientData

1. 데이터셋 적재 2. 모델을 Redis-ML에 저장

3. 실시간 서비스

• Getting Ready to Use Redis with Apache Spark (by Redis Labs) [sli

de, video]

• Redis를 사용하여 Spark ML에서 학습된 모델을 실시간으로 서비스

하는 방법을 소개

Redis with Apache Spark

• Redis

– In-memory Key Value Storage

• Redis Module

– Redis에서 동작시킬 수 있는 일종의 플러그인

– 동적으로 링크될 수 있는 c library (.so) 형태로 저장됨

Redis with Apache Spark

• Redis-ML

– ML Model을 저장하고 사용할 수 있게 해 주는 Redis Module

– https://github.com/RedisLabsModules/redis-ml

• Spark-Redis-ML

– Redis-ML을 Spark에서 사용할 수 있게 해 주는 connector

– https://github.com/redislabs/spark-redis-ml

• 예제: http://bit.ly/sparkredisml

Redis with Apache Spark

• 예제: Random Forest [documentation]

• Forest에 Tree 추가

• 예측

ML.FOREST.ADD <forestId> <treeId> <path> \

[ [NUMERIC|CATEGORIC] <splitterAttr> <splitterVal> ] \

| [LEAF] <predVal>

ML.FOREST.RUN <forestId> <features> \

[CLASSIFICATION|REGRESSION]

> MODULE LOAD “./redis-ml.so”

OK

> ML.FOREST.ADD myforest 0 . CATEGORIC sex “male” .L LEAF 1 .R LEAF 0

OK

> ML.FOREST.RUN myforest sex:male

“1”

> ML.FOREST.RUN myforest sex:something_else

“0”

Redis with Apache Spark

“myforest라는 분류형 random forest 모델의 0번

Decision Tree의 root에 성별이 male이면 1을, 아

니면 0을 리턴하는 Node를 추가해라.“

Redis with Apache Spark

• Spark-Redis-ML

// rfModel : 머신 러닝 알고리즘을 사용해서 학습된 모델 객체

val rfModel: PipelineModel = pipeline.stages(2)

.asInstanceOf[RandomForestClassificationModel]

// Redis-ML에 Forest 타입으로 저장

val f: Forest = new Forest(rfModel.trees)

f.loadToRedis("myforest", ”xx.xxx.xx.x")

// 예측: String in, String out

jedis.getClient.sendCommand(

MLClient.ModuleCommand.FOREST_RUN, "myforest", record_vec_str)

Redis with Apache Spark

• 관련 세션

– Building a Large Scale Recommendation Engine with Spark

and Redis-ML [slide, video]

– Real-Time Machine Learning with Redis, Apache Spark, Tensor

Flow, and more [slide, video]

Automated Machine Learning

• Embracing a Taxonomy of Types to Simplify Machine Learning

[slide, video]

• Machine Learning 작업에 있어서 반복되는 작업들을 자동화

– In-House Library: ‘Optimus Prime’

FeatureEngineer-

ing

ModelSelection

Training

시행 착오 = 시간 = 비용!

Automated Machine Learning

• Feature Engineering

– 주어진 Data를 어떻게 Feature Vector로 나타낼 것인가?

– Parsing, Converting, Sanity Checking, …

• Model Selection

– 주어진 Vector 집합(=Training Dataset)에 가장 잘 맞는 Model은

무엇인가?

Automated Machine Learning

• Quiz 1: 아래 선택지 중 의미가 가장 다른 것은?

1. 서울특별시 강남구 역삼로 180

2. 서울특별시 강남구 역삼동 790-6

3. 135-841

4. 06248

5. 42

• 구주소 vs 신주소? 광역자치단체? 기초자치단체?

– 어떻게 하느냐에 따라 같은 레코드에서도 전혀 다른 Vector값이 나온다!

Automated Machine Learning

• Quiz 2: Integer ’32’ 는 무슨 의미일까?

– 나이

– Percentage

– 날짜

– 32달러? 32위안?

• 같아 보이는 값도 구체적인 의미는 다를 수 있고, 그에 따라 Sanity

Check 방식도 달라짐

Automated Machine Learning

• 정리하자면…

– 임의의 속성 Record에 대해 (반복되는) Feature Type을 정의할

수 있음

– 결정된 Feature Type에 대해 아래 세 가지를 정의해야 함:

1. Parsing

2. Converting

3. Sanity Checking

Automated Machine Learning

• Feature Engineering: 해결 방법

– 자주 사용되는 Feature Type의 상속 관계와 인터페이스를 정의 (다음

슬라이드!)

– Parsing, Vectorize, Sanity Checking 구현체를 사내에서 공유

val vectorizeByProvince = Seq(addressVectorizor).vectorize()

val vectorizeByAgeAndProvince =

Seq(ageVectorizor, addressVectorizor).vectorize()

Automated Machine Learning

Automated Machine Learning

• Model Selection

– 자동으로 적당한 Model을 찾아 주는 시스템

Extending Spark Machine Learning

• Extending Spark Machine Learning: Adding Your Own Algorithms

and Tools [video]

• Spark ML Pipeline 기본 + Custom 알고리즘을 구현하는 방법

Extending Spark Machine Learning

• Spark ML 초심자를 위한 초고속 요점정리

• 4:48 ~ 18:11!!

Questions…?

Recommended