Pipelines Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are two ways to display the steps in a pipeline?

A
# Text version:
print(my_pipeline)
# Visual/diagram version:
from sklearn import set_config
set_config(display='diagram') # display='text' is how you undo this
print(my_pipeline)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two methods of a pipeline and what do they do?

A

.fit(): calls the .fit_transform() method of each transformer component and then calls the .fit() method of the terminal predictor (if one is present)

.predict(): calls the .transform() method of each transformer component and then calls the .predict() method of the terminal predictor (if one is present)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Provide example syntax of defining and running a simple pipeline with one transformer (StandardScaler) and one predictor (LinerRegression).

A

pipe = Pipeline([(“feature scaling”, StandardScaler()),
(“linear regression”, LinearRegression())])

pipe. fit(X_train, y)
pipe. predict(X-test)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to spell out the steps of a pipeline?

How to access the attributes of a particular step?

A

pipe.named_steps

# Works like a dict:
pipe.named_steps['linear regression'].coef_
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to spell out the parameters of every step of a pipeline?

A

my_pipe.get_params()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you combine a pipeline with a grid search?

A
  1. Feed entire pipeline into the grid search - this one is intuitive

OR

  1. Have the grid search as one step in the pipeline - not so intuitive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly