0

I am trying to implement oversampling using Smote and increase the f1 score. I am using a grid search and logistic regression as a classifier.

    k_neighbors = [np.linspace(1, 10, 10)]
    pipe = make_pipeline(SMOTE(),LogisticRegression())
    weights = np.linspace(0.005, 0.25, 10)k_neighbors = [np.linspace(1, 10, 10)]
    pipe = make_pipeline(SMOTE(),LogisticRegression())
    gsc = GridSearchCV(estimator=pipe,param_grid={'k__neighbors': k_neighbors},scoring='f1',cv=3)
    grid_result = gsc.fit(X_train, Y_train)

I've tried multiple things and I'm still getting following error. If anyone could solve this for me, it would be a great help.

`ValueError: Invalid parameter 'k' for estimator Pipeline(steps=[('smote', SMOTE()),`
`('logisticregression', LogisticRegression())]). Valid parameters are: ['memory', 'steps', 'verbose'].`
  • Hi megha, do you check this link before? : [Using Smote with Gridsearchcv in Scikit-learn](https://stackoverflow.com/questions/50245684/using-smote-with-gridsearchcv-in-scikit-learn) – Emre Ç. Jun 27 '23 at 10:55

0 Answers0