Kroky ML modelování

Machine Learning for Marketing in Python

Karolis Urbonas

Head of Analytics & Science, Amazon

Kroky učení s učitelem

  1. Rozdělení dat na trénovací a testovací
  2. Inicializace modelu
  3. Trénování modelu na trénovacích datech
  4. Predikce hodnot na testovacích datech
  5. Měření výkonu modelu na testovacích datech
Machine Learning for Marketing in Python

Učení s učitelem s kódem

Nejprve načteme knihovny.

from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
Machine Learning for Marketing in Python

Kroky učení s učitelem s kódem

# 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 for Marketing in Python

Kroky učení bez učitele

  1. Inicializace modelu
  2. Trénování modelu
  3. Přiřazení hodnot clusterů
  4. Prozkoumání výsledků
Machine Learning for Marketing in Python

Učení bez učitele s kódem

Nejprve načteme knihovny.

from sklearn.cluster import KMeans
import pandas as pd
Machine Learning for Marketing in Python

Učení bez učitele s kódem

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 for Marketing in Python

Pojďme sestavit modely!

Machine Learning for Marketing in Python

Preparing Video For Download...