MCPcopy
hub / github.com/mne-tools/mne-python / _transform

Method _transform

mne/decoding/search_light.py:505–536  ·  view source on GitHub ↗

Aux. function to make parallel predictions/transformation.

(self, X, method)

Source from the content-addressed store, hash-verified

503 return repr_str
504
505 def _transform(self, X, method):
506 """Aux. function to make parallel predictions/transformation."""
507 X, is_nd = self._check_Xy(X)
508 check_is_fitted(self)
509 orig_method = method
510 method = _check_method(self.base_estimator, method)
511
512 parallel, p_func, n_jobs = parallel_func(
513 _gl_transform,
514 self.n_jobs,
515 max_jobs=X.shape[-1],
516 verbose=_verbose_safe_false(),
517 )
518
519 context = _create_progressbar_context(self, X, "Transforming")
520 with context as pb:
521 y_pred = parallel(
522 p_func(self.estimators_, x_split, method, pb.subset(pb_idx))
523 for pb_idx, x_split in array_split_idx(
524 X, n_jobs, axis=-1, n_per_split=len(self.estimators_)
525 )
526 )
527
528 y_pred = np.concatenate(y_pred, axis=2)
529 if orig_method == "transform":
530 y_pred = y_pred.astype(X.dtype)
531 if (
532 orig_method in ("predict", "predict_proba", "decision_function")
533 and not is_nd
534 ):
535 y_pred = y_pred.squeeze()
536 return y_pred
537
538 def transform(self, X):
539 """Transform each data slice with all possible estimators.

Callers 4

transformMethod · 0.95
predictMethod · 0.95
predict_probaMethod · 0.95
decision_functionMethod · 0.95

Calls 7

parallel_funcFunction · 0.85
_verbose_safe_falseFunction · 0.85
array_split_idxFunction · 0.85
_check_XyMethod · 0.80
subsetMethod · 0.80
_check_methodFunction · 0.70

Tested by

no test coverage detected