from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
# Define a Pipeline
pipe = Pipeline([('imputer', SimpleImputer()),
('scaler', StandardScaler()),
('regressor', LogisticRegression())])
# Access the first two steps in the Pipeline
first_two_steps = pipe[:2]
# Access the last step in the Pipeline
last_step = pipe[-1:]
# Access the middle step in the Pipeline
middle_step = pipe[1:2]
#Printing the result
print(first_two_steps)
print(last_step)
print(middle_step)