user3668129:
私が使用しているpython 3.7.6
、と私は同調するように使用して、いくつかのハイパーしようとしていますGridSearchCV
私が作成したpipeline
以下の手順では:scaling-> feature selection -> model
しかし、私はというエラーを取得していますC
特徴選択ステップのパラメータ。
steps = [('scaler', StandardScaler()),
('FeatureSelection', SelectFromModel(LogisticRegression(penalty='l1', solver='liblinear'))),
('SVM', SVC())]
pipeline = Pipeline(steps) # define the pipeline object.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=30, stratify=y)
parameteres = {'SVM__C': [0.001, 0.1, 10, 100, 10e5],
'SVM__gamma':[0.1,0.01],
'FeatureSelection__C':['0','0.5']}
grid = GridSearchCV(pipeline, param_grid=parameteres, cv=5, n_jobs=-1)
grid.fit(X_train, y_train)
print("pipeline score: ", grid.score(X_test, y_test))
私は次のエラーを取得しています:
ValueError: Invalid parameter C for estimator SelectFromModel(estimator=LogisticRegression(C=1.0, class_weight=None,
dual=False, fit_intercept=True,
intercept_scaling=1, l1_ratio=None,
max_iter=100, multi_class='auto',
n_jobs=None, penalty='l1',
random_state=None,
solver='liblinear', tol=0.0001,
verbose=0, warm_start=False),
max_features=None, norm_order=1, prefit=False, threshold=None). Check the list of available parameters with `estimator.get_params().keys()`.
何が間違っているとどのように私はそれを修正することができますか?
desertnaut:
パラメータのためのパイプラインのルックスであるC
中SelectFromModel
、(モジュールは、このようなパラメータを持っていないので、当然)ものを見つけることができず、エラーが発生します。あなたが実際にパラメータたいのでC
のをLogisticRegression
、あなたはより深いレベルに行く必要があります。変更FeatureSelection__C
にFeatureSelection__estimator__C
あなたの中にparameters
グリッドを、あなたは罰金になります。