回帰モデル

Python によるモデル検証

Kasey Jones

Data Scientist

scikit-learn のランダムフォレスト

from sklearn.ensemble import RandomForestRegressor
from sklearn.ensemble import RandomForestClassifier
rfr = RandomForestRegressor(random_state=1111)
rfc = RandomForestClassifier(random_state=1111)
Python によるモデル検証

決定木は全データ点から始まり、上から分割していきます。各データ点の特徴に基づき、枝をたどって分類・予測します。

Python によるモデル検証

ランダムフォレストは、各データ点について複数の決定木の予測を平均し、最終予測を出します。

Python によるモデル検証

ランダムフォレストのパラメータ

n_estimators:森の木の本数

max_depth:各木の最大深さ

random_state:乱数シード

from sklearn.ensemble import RandomForestRegressor
rfr = RandomForestRegressor(n_estimators=50, max_depth=10)
rfr = RandomForestRegressor(random_state=1111)
rfr.n_estimators = 50
rfr.max_depth = 10
Python によるモデル検証

特徴量重要度

各列のモデルへの重要度を表示

for i, item in enumerate(rfr.feature_importances_):
    print("{0:s}: {1:.2f}".format(X.columns[i], item))
weight: 0.50
height: 0.39
left_handed: 0.72
union_preference: 0.05
eye_color: 0.03
Python によるモデル検証

始めましょう

Python によるモデル検証

Preparing Video For Download...