python 2.7 - Parameter tuning using GridSearchCV -


i using pipeline in gridsearch cv object tune parameters.my code follows

x_train = df_train.drop("saleprice", axis=1) y_train = df_train["saleprice"] x_test  = df_test.drop("id", axis=1).copy() sklearn.linear_model import linearregression lr = linearregression() sklearn.preprocessing import minmaxscaler sklearn.grid_search import gridsearchcv sklearn.decomposition import pca sklearn.pipeline import pipeline scaler = minmaxscaler() param_grid={'features__pca__n_components':[1, 2, 3,5,10],} pipeline = pipeline(steps=[('scaler', scaler),('algorithm',lr)]) gs = gridsearchcv(pipeline, param_grid, scoring='f1') gs.fit(x_train, y_train) print "best estimator",gs.best_estimator_ clf = gs.best_estimator_ # fit optimal model clf.fit(x_train, y_train) # predict based on optimal model pred = clf.predict(x_test) acc_log = round(clf.score(x_train, y_train) * 100, 2) acc_log 

i getting error x_train , y_train parameters numpy arrays.

valueerror                                traceback (most recent call last) <ipython-input-681-9e3b37600170> in <module>()       7 pipeline = pipeline(steps=[('scaler', scaler),('algorithm',lr)])       8 gs = gridsearchcv(pipeline, param_grid, scoring='f1') ----> 9 gs.fit(x_train, y_train)      10 print "best estimator",gs.best_estimator_      11 clf = gs.best_estimator_   valueerror: invalid parameter features estimator pipeline(steps=[('scaler', minmaxscaler(copy=true, feature_range=(0, 1))), ('algorithm', linearregression(copy_x=true, fit_intercept=true, n_jobs=1, normalize=false))]). check list of available parameters `estimator.get_params().keys()`. 

how should configure parameters?

kindly me solve this.thanks


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -