scikit_learnのExtraTreesRegressorをgridsearchCVでチューニングするときにエラーが起きています。
エラーは以下の通りです。
ValueError: Invalid parameter n_estimaters for estimator ExtraTreesRegressor(bootstrap=False, criterion='mse', max_depth=None,
max_features=0.1, max_leaf_nodes=None, min_impurity_decrease=0.0,
min_impurity_split=None, min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0, warm_start=False). Check the list of available parameters with estimator.get_params().keys()
.
python
1コード``` 2import numpy as np 3import pandas as pd 4from sklearn.model_selection import GridSearchCV 5from sklearn.ensemble import ExtraTreesRegressor 6from sklearn.metrics import r2_score 7from sklearn.metrics import mean_squared_error 8from sklearn.metrics import mean_absolute_error 9 10sample_data = pd.read_csv('transformed_include_error_4.csv') 11sample_data = sample_data.query('Error ==0') 12 13sample_data = pd.read_csv('transformed_include_error_4.csv') 14test_data = sample_data.query('Error ==0') 15 16np.random.seed(seed=42) 17indices = np.random.permutation(len(sample_data)) 18train_size = 140 19train_idx, test_idx = indices[:train_size], indices[train_size:] 20 21train_data = sample_data.iloc[train_idx] 22test_data = test_data.iloc[test_idx] 23 24y_train = train_data['Rate'] 25x_train = train_data.loc[:,["feature_1","feature_2","feature_3","feature_4"]] 26 27y_test = test_data['Rate'] 28x_test = test_data.loc[:,["feature_1","feature_2","feature_3","feature_4"]] 29 30params = { 31 "n_estimaters":[100], 32 "max_features":[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9], 33 "random_state":[42] 34} 35 36clf = GridSearchCV( 37 ExtraTreesRegressor(), 38 params, 39 cv=10, 40 scoring = "r2" 41) 42clf.fit(x_train,y_train)
回答1件
あなたの回答
tips
プレビュー