scikit-learnでall_estimatroを使って、各アルゴリズムのirisデータに対する学習の正解率を比較したいです。
python
1#各アルゴリズムの正解率を比較する 2 3import warnings 4from sklearn.utils.testing import all_estimators 5from sklearn.model_selection import train_test_split 6from sklearn.metrics import accuracy_score 7from sklearn.datasets import load_iris 8 9data = load_iris() 10 11df = pd.DataFrame(data.data, columns=data.feature_names) 12x = data.data 13y = data.target 14x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.2,shuffle = True) 15 16warnings.filterwarnings('ignore') 17allAlgorithms = all_estimators(type_filter='classifier') 18 19for name, algorithm in allAlgorithms: 20 model = algorithm() 21 model.fit(x_train,y_train) 22 y_pred = model.predict(x_test) 23 print('{0}の正解率は'.format(name),accuracy_score(y_pred,y_test)) 24
とすると以下のようなエラーメッセージが出てきてしまいます。
エラーメッセージ
AdaBoostClassifierの正解率は 0.9333333333333333 BaggingClassifierの正解率は 0.9333333333333333 BernoulliNBの正解率は 0.26666666666666666 CalibratedClassifierCVの正解率は 0.9 CheckingClassifierの正解率は 0.3333333333333333 --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-124-b60aa911d1ba> in <module> 18 19 for name, algorithm in allAlgorithms: ---> 20 model = algorithm() 21 model.fit(x_train,y_train) 22 y_pred = model.predict(x_test) TypeError: __init__() missing 1 required positional argument: 'base_estimator' 1
おそらく、warnings関数がうまく働いていないと思うのですが、どのようにすれば解決するのでしょうか。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。