0

グリッド検索の実行中にエラーが発生しましたが、誰か助けてもらえますか? このエラーを解決できません。

私のコード:

# get feature and label data
feature_data = creditcard_data.loc[:, creditcard_data.columns != 'Class']
label_data = creditcard_data.loc[:, creditcard_data.columns == 'Class']

from imblearn.pipeline import Pipeline
from imblearn.pipeline import make_pipeline
from sklearn.model_selection import GridSearchCV

pipe = make_pipeline(
    SMOTE(),
    LogisticRegression()
)

pipe.get_params().keys()

weights = np.linspace(0.005, 0.05, 10)

gsc = GridSearchCV(estimator=pipe,
                   param_grid={
                       # 'smote__ratio': [{0: int(num_neg), 1: int(num_neg * w) } for w in weights]
                       'smote': weights},
                   scoring='f1',
                   cv=3)

grid_results = gsc.fit(testdf_feature, testdf_label)

print("Best parameters : %s" % grid_result.best_params_)

# Plot the weights vs f1 score
dataz = pd.DataFrame({'score': grid_result.cv_results_['mean_test_score'],
                      'weight': weights})
dataz.plot(x='weight')

このエラーが発生しています:

TypeError: チェーンのすべての中間ステップは、fit と transform または fit_resample (両方ではない) を実装する推定器であるか、文字列 'passthrough' '0.005' (type ) である必要があります)。

4

0 に答える 0