ML 모델링 단계

Python으로 배우는 마케팅용 Machine Learning

Karolis Urbonas

Head of Analytics & Science, Amazon

지도 학습 단계

  1. 데이터를 학습/테스트로 분할
  2. 모델 초기화
  3. 학습 데이터로 모델 학습
  4. 테스트 데이터로 예측
  5. 테스트 데이터에서 성능 평가
Python으로 배우는 마케팅용 Machine Learning

코드로 하는 지도 학습

먼저 라이브러리를 불러옵니다.

from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
Python으로 배우는 마케팅용 Machine Learning

코드로 보는 지도 학습 단계

# 1. Split data to training and testing
train_X, test_X, train_Y, test_Y = train_test_split(X, Y, test_size=0.25)

# 2. Initialize the model mytree = tree.DecisionTreeClassifier()
# 3. Fit the model on the training data treemodel = mytree.fit(train_X, train_Y)
# 4. Predict values on the testing data pred_Y = treemodel.predict(test_X)
# 5. Measure model performance on testing data accuracy_score(test_Y, pred_Y)
Python으로 배우는 마케팅용 Machine Learning

비지도 학습 단계

  1. 모델 초기화
  2. 모델 학습
  3. 군집 값 할당
  4. 결과 탐색
Python으로 배우는 마케팅용 Machine Learning

코드로 하는 비지도 학습

먼저 라이브러리를 불러옵니다.

from sklearn.cluster import KMeans
import pandas as pd
Python으로 배우는 마케팅용 Machine Learning

코드로 하는 비지도 학습

1. Initialize the model
kmeans = KMeans(n_clusters=3)

# Fit the model kmeans.fit(data)
# 3. Asign cluster values data.assign(Cluster=kmeans.labels_)
# 4. Explore results data.groupby('Cluster').mean()
Python으로 배우는 마케팅용 Machine Learning

모델을 만들어 봅시다!

Python으로 배우는 마케팅용 Machine Learning

Preparing Video For Download...