Pythonでランダムフォレストのハイパーパラメータを求めたいと考えています。
Python
1forest = RandomForestRegressor() 2forest.fit(train_features, train_labels)
以上のコードは実行されるのに対し、
Python
1# ハイパーパラメータ 2forest_grid_param = { 3 'n_estimators': [100], 4 'max_features': [1, 'auto', None], 5 'max_depth': [1, 5, 10, None], 6 'min_samples_leaf': [1, 2, 4,] 7} 8 9# スコア方法をF1に設定 10f1_scoring = make_scorer(f1_score, pos_label=1) 11 12# グリッドサーチで学習 13forest_grid_search = GridSearchCV(RandomForestClassifier(random_state=0, n_jobs=-1), forest_grid_param, scoring=f1_scoring, cv=4) 14forest_grid_search.fit(train_features, train_labels)
以上のコードでは、
ValueError: Target is multiclass but average='binary'. Please choose another average setting.
以上のようなエラーが出てしまいます。
グリッドリサーチとランダムフォレストのfitでは、なにか違いがあるのでしょうか。
train_featuresは、
[[ 1.29289835e-04 1.17485219e-04 1.19890843e-04 ..., 9.05183214e-05 8.27563718e-05 8.78005056e-05] [ 1.49255279e-04 1.35313449e-04 1.36294066e-04 ..., 8.62639847e-05 9.09304063e-05 7.84873169e-05] [ 1.88674124e-04 1.92549213e-04 1.94561864e-04 ..., 1.27251725e-04 1.32504809e-04 1.19707440e-04] ..., [ 1.16313098e-05 2.90295617e-05 3.99510497e-05 ..., 1.52137304e-05 1.43487523e-05 3.92287642e-05] [ 1.58036700e-05 3.00034379e-05 3.78270972e-05 ..., 1.91663956e-05 2.44618265e-05 2.47100536e-05] [ 5.88701713e-05 3.20351268e-05 1.23424729e-05 ..., 2.63503805e-05 4.25346609e-05 3.44451908e-05]]
以上のような形式です。
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/05 15:38
2018/01/06 01:57
2018/01/06 05:48
2018/01/06 05:59
2018/01/06 06:03
2018/01/06 06:25