In the sklearn library, when using the Pipeline
class, it is possible to modify the parameters of the nested estimators. This
modification can be done by using the Pipeline
method set_params
and specifying the name of the estimator and the parameter
to update separated by a double underscore __
.
from sklearn.pipeline import Pipeline
from sklearn.svm import SVC
pipe = Pipeline(steps=[("clf", SVC())])
pipe.set_params(clf__C=10)
In the example above, the regularization parameter C
is set to the value 10
for the classifier called clf
.
Setting such parameters can be done as well with the help of the param_grid
parameter for example when using
GridSearchCV
.
Providing invalid parameters that do not exist on the estimator can lead to unexpected behavior or runtime errors.
This rule checks that the parameters provided to the set_params
method of a Pipeline instance or through the param_grid
parameters of a GridSearchCV
are valid for the nested estimators.