調整你的模型

行銷分析:用 Python 預測客戶流失

Mark Peterson

Director of Data Science, Infoblox

快速複習

from sklearn.svm import SVC

svc = SVC()

svc.fit(telco['data'], telco['target'])
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
  decision_function_shape='ovr', degree=3, gamma='scale', kernel='rbf',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False)
行銷分析:用 Python 預測客戶流失

隨機森林超參數

參數 目的
n_estimators 樹的數量
criterion 切分品質
max_features 最佳切分時的特徵數
max_depth 樹的最大深度
min_sample_splits 節點切分的最小樣本數
bootstrap 是否使用 Bootstrap 樣本
行銷分析:用 Python 預測客戶流失

網格搜尋

行銷分析:用 Python 預測客戶流失

在 sklearn 進行網格搜尋

from sklearn.model_selection import GridSearchCV

param_grid = {'n_estimators': np.arange(10, 51)}
clf_cv = GridSearchCV(RandomForestClassifier(), param_grid)
clf_cv.fit(X, y)
clf_cv.best_params_
{'n_estimators': 43}
clf_cv.best_score_
0.9237923792379238
行銷分析:用 Python 預測客戶流失

調參順利!

行銷分析:用 Python 預測客戶流失

Preparing Video For Download...