|
15 | 15 |
|
16 | 16 | from sklearn import pipeline |
17 | 17 | from sklearn.base import clone |
| 18 | +from sklearn.utils import Bunch, _print_elapsed_time |
18 | 19 | from sklearn.utils.metaestimators import if_delegate_has_method |
19 | 20 | from sklearn.utils.validation import check_memory |
20 | 21 |
|
@@ -60,7 +61,7 @@ class Pipeline(pipeline.Pipeline): |
60 | 61 |
|
61 | 62 | Attributes |
62 | 63 | ---------- |
63 | | - named_steps : dict |
| 64 | + named_steps : bunch object, a dictionary with attribute access |
64 | 65 | Read-only attribute to access any step parameter by user given name. |
65 | 66 | Keys are step names and values are steps parameters. |
66 | 67 |
|
@@ -178,6 +179,13 @@ def _fit(self, X, y=None, **fit_params): |
178 | 179 | name: {} for name, step in self.steps if step is not None |
179 | 180 | } |
180 | 181 | for pname, pval in fit_params.items(): |
| 182 | + if '__' not in pname: |
| 183 | + raise ValueError( |
| 184 | + "Pipeline.fit does not accept the {} parameter. " |
| 185 | + "You can pass parameters to specific steps of your " |
| 186 | + "pipeline using the stepname__parameter format, e.g. " |
| 187 | + "`Pipeline.fit(X, y, logisticregression__sample_weight" |
| 188 | + "=sample_weight)`.".format(pname)) |
181 | 189 | step, param = pname.split("__", 1) |
182 | 190 | fit_params_steps[step][param] = pval |
183 | 191 | for step_idx, name, transformer in self._iter(with_final=False): |
|
0 commit comments