ขั้นตอนการสร้างโมเดล ML

Machine Learning สำหรับการตลาดด้วย Python

Karolis Urbonas

Head of Analytics & Science, Amazon

ขั้นตอน Supervised Learning

  1. แบ่งข้อมูลเป็นชุดฝึกและชุดทดสอบ
  2. กำหนดค่าเริ่มต้นโมเดล
  3. ฝึกโมเดลด้วยข้อมูลชุดฝึก
  4. พยากรณ์ค่าจากข้อมูลชุดทดสอบ
  5. วัดประสิทธิภาพของโมเดลบนข้อมูลชุดทดสอบ
Machine Learning สำหรับการตลาดด้วย Python

Supervised Learning ด้วยโค้ด

เริ่มต้นด้วยการโหลดไลบรารี

from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
Machine Learning สำหรับการตลาดด้วย Python

ขั้นตอน Supervised 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)
Machine Learning สำหรับการตลาดด้วย Python

ขั้นตอน Unsupervised Learning

  1. กำหนดค่าเริ่มต้นโมเดล
  2. ฝึกโมเดล
  3. กำหนดค่าคลัสเตอร์
  4. สำรวจผลลัพธ์
Machine Learning สำหรับการตลาดด้วย Python

Unsupervised Learning ด้วยโค้ด

เริ่มต้นด้วยการโหลดไลบรารี

from sklearn.cluster import KMeans
import pandas as pd
Machine Learning สำหรับการตลาดด้วย Python

Unsupervised 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()
Machine Learning สำหรับการตลาดด้วย Python

มาสร้างโมเดลกันเลย!

Machine Learning สำหรับการตลาดด้วย Python

Preparing Video For Download...