Back to questions
JuniorTheoryCommon
What happens when this program runs?
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
pipe = Pipeline([("scaler", StandardScaler()), ("model", LogisticRegression())])
pipe.set_params(C=0.1)
print(pipe.named_steps["model"].C)set_params raises ValueError: the step's parameter is named model__C
- Expecting the pipeline to route
Cto the model: it looks the name up among its own parameters and raisesValueError; a step's parameter is set asmodel__C=0.1. - Expecting an unknown name to be skipped silently: scikit-learn checks every name passed to
set_paramsand refuses one the pipeline does not have.
- How would you set
Cof themodelstep to0.1correctly? - Why does a pipeline need the step name inside a parameter's name?