parameters using pipelineswe can encapsulate all the processing steps in our machine learning workflow in single scikit-learn estimator another benefit of doing this is that we can now adjust the parameters of the preprocessing using the outcome of supervised task like regression or classification in previous we used polynomial features on the boston dataset before applying the ridge regressor let' model that using pipeline instead the pipeline contains three steps--scaling the datacomputing polynomial featuresand ridge regressionin[ ]from sklearn datasets import load_boston boston load_boston(x_trainx_testy_trainy_test train_test_split(boston databoston targetrandom_state= from sklearn preprocessing import polynomialfeatures pipe make_pipelinestandardscaler()polynomialfeatures()ridge()how do we know which degrees of polynomials to chooseor whether to choose any polynomials or interactions at allideally we want to select the degree parameter based on the outcome of the classification using our pipelinewe can search over the degree parameter together with the parameter alpha of ridge to do thiswe define param_grid that contains bothappropriately prefixed by the step namesin[ ]param_grid {'polynomialfeatures__degree'[ ]'ridge__alpha'[ ]now we can run our grid search againin[ ]grid gridsearchcv(pipeparam_grid=param_gridcv= n_jobs=- grid fit(x_trainy_trainwe can visualize the outcome of the cross-validation using heat map (figure - )as we did in in[ ]plt matshow(grid cv_results_['mean_test_score'reshape( - )vmin= cmap="viridis"plt xlabel("ridge__alpha"plt ylabel("polynomialfeatures__degree"grid-searching preprocessing steps and model parameters