0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【備忘録】it does not seem to be a scikit-learn estimator as it does not implement a 'get_params' methods【sklearn】

Posted at

#概要

sklearnを使ってる時、下記のようにBagging等のアンサンブルをしてる時に

from sklearn.model_selection import train_test_split
from sklearn.ensemble import BaggingClassifier
from sklearn.tree import DecisionTreeClassifier
import numpy as np

#X 何かのデータ
#Y 何かのラベル
Train_X,Test_X,Train_Y,Test_Y=train_test_split(X,Y,train_size=0.8,shuffle=True)

B_dtree_clf = BaggingClassifier(base_estimator=DecisionTreeClassifier,n_jobs=12)
B_dtree_clf.fit(Train_X,Train_Y)

これを実行すると
it does not seem to be a scikit-learn estimator as it does not implement a 'get_params' methods

が出るときがある。どういうこと?って思うが、単純な話だった。以下のコードが正解

from sklearn.model_selection import train_test_split
from sklearn.ensemble import BaggingClassifier
from sklearn.tree import DecisionTreeClassifier
import numpy as np

#X 何かのデータ
#Y 何かのラベル
Train_X,Test_X,Train_Y,Test_Y=train_test_split(X,Y,train_size=0.8,shuffle=True)

B_dtree_clf = BaggingClassifier(base_estimator=DecisionTreeClassifier(),n_jobs=12)
B_dtree_clf.fit(Train_X,Train_Y)

間違い探しです。どこが違うでしょうか。

...答えは()が足りなかっただけです。本当にありがとうございました(

#元々どういうエラー?

TensorFlowとかで作ったモデルをアンサンブルしたい時とかに、必要な機能が足りてないという意味のエラーっぽい
自作モデルをSklearnでアンサンブルする作り方はこちらのブログを参考にどうぞ。
(自分も記事書くかも)

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?