Aux. function to make parallel predictions/transformation.
(self, X, method)
| 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. |
no test coverage detected