fit the pipeline defined before to the cancer dataset pipe fit(cancer dataextract the first two principal components from the "pcastep components pipe named_steps["pca"components_ print("components shape{}format(components shape)out[ ]components shape( accessing attributes in grid-searched pipeline as we discussed earlier in this one of the main reasons to use pipelines is for doing grid searches common task is to access some of the steps of pipeline inside grid search let' grid search logisticregression classifier on the cancer datasetusing pipeline and standardscaler to scale the data before passing it to the logisti cregression classifier first we create pipeline using the make_pipeline functionin[ ]from sklearn linear_model import logisticregression pipe make_pipeline(standardscaler()logisticregression()nextwe create parameter grid as explained in the regularization parameter to tune for logisticregression is the parameter we use logarithmic grid for this parametersearching between and because we used the make_pipeline functionthe name of the logisticregression step in the pipeline is the lowercased class namelogisticregression to tune the parameter cwe therefore have to specify parameter grid for logisticregression__cin[ ]param_grid {'logisticregression__c'[ ]as usualwe split the cancer dataset into training and test setsand fit grid searchin[ ]x_trainx_testy_trainy_test train_test_splitcancer datacancer targetrandom_state= grid gridsearchcv(pipeparam_gridcv= grid fit(x_trainy_trainso how do we access the coefficients of the best logisticregression model that was found by gridsearchcvfrom we know that the best model found by gridsearchcvtrained on all the training datais stored in grid best_estimator_the general pipeline interface