MCPcopy
hub / github.com/scikit-learn/scikit-learn / _check_method_params

Method _check_method_params

sklearn/pipeline.py:412–439  ·  view source on GitHub ↗
(self, method, props, **kwargs)

Source from the content-addressed store, hash-verified

410 return "(step %d of %d) Processing %s" % (step_idx + 1, len(self.steps), name)
411
412 def _check_method_params(self, method, props, **kwargs):
413 if _routing_enabled():
414 routed_params = process_routing(self, method, **props, **kwargs)
415 return routed_params
416 else:
417 fit_params_steps = Bunch(
418 **{
419 name: Bunch(**{method: {} for method in METHODS})
420 for name, step in self.steps
421 if step is not None
422 }
423 )
424 for pname, pval in props.items():
425 if "__" not in pname:
426 raise ValueError(
427 "Pipeline.fit does not accept the {} parameter. "
428 "You can pass parameters to specific steps of your "
429 "pipeline using the stepname__parameter format, e.g. "
430 "`Pipeline.fit(X, y, logisticregression__sample_weight"
431 "=sample_weight)`.".format(pname)
432 )
433 step, param = pname.split("__", 1)
434 fit_params_steps[step]["fit"][param] = pval
435 # without metadata routing, fit_transform and fit_predict
436 # get all the same params and pass it to the last fit.
437 fit_params_steps[step]["fit_transform"][param] = pval
438 fit_params_steps[step]["fit_predict"][param] = pval
439 return fit_params_steps
440
441 def _get_metadata_for_step(self, *, step_idx, step_params, all_params):
442 """Get params (metadata) for step `name`.

Callers 3

fitMethod · 0.95
fit_transformMethod · 0.95
fit_predictMethod · 0.95

Calls 5

BunchClass · 0.90
_routing_enabledFunction · 0.85
process_routingFunction · 0.85
formatMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected