Examine steps of pipeline using "Sci-kit learn"

A pipeline is a series of steps that transform data and apply a machine learning algorithm to make predictions. Understanding the different steps of a pipeline is crucial for successfully building and deploying machine learning models. In this thread, we will discuss some ways to examine the steps of a pipeline using Sci-kit learn.

Loading "dataset" and creating "pipeline":

First, let's load the iris dataset and split it into training and testing sets. Then, create a pipeline that applies linear regression to the data and fit the pipeline to the training data. Let's understand below:

To examine the steps of the pipeline, we can use the following methods:

1. Using "pipeline.steps" :

It returns a list of tuples, where each tuple contains the name of the step and the actual estimator object. For example:

2. Using "pipeline.named_steps" :

It returns a dictionary that maps step names to estimator objects. For example:

3. Using "pipeline.get_params" :

It returns a dictionary of parameter names mapped to their values for each step in the pipeline. For example:

4. Using "pipeline.score" :

It method returns the R^2 coefficient of determination for the pipeline. For example: