Score each estimator on each task. The number of tasks in X should match the number of tasks/estimators given at fit time, i.e. we need ``X.shape[-1] == len(self.estimators_)``. Parameters ---------- X : array, shape (n_samples, nd_features, n_tasks)
(self, X, y)
| 303 | return X, is_nd |
| 304 | |
| 305 | def score(self, X, y): |
| 306 | """Score each estimator on each task. |
| 307 | |
| 308 | The number of tasks in X should match the number of tasks/estimators |
| 309 | given at fit time, i.e. we need |
| 310 | ``X.shape[-1] == len(self.estimators_)``. |
| 311 | |
| 312 | Parameters |
| 313 | ---------- |
| 314 | X : array, shape (n_samples, nd_features, n_tasks) |
| 315 | The input samples. For each data slice, the corresponding estimator |
| 316 | scores the prediction, e.g.: |
| 317 | ``[estimators[ii].score(X[..., ii], y) for ii in range(n_estimators)]``. |
| 318 | The feature dimension can be multidimensional e.g. |
| 319 | X.shape = (n_samples, n_features_1, n_features_2, n_tasks). |
| 320 | y : array, shape (n_samples,) | (n_samples, n_targets) |
| 321 | The target values. |
| 322 | |
| 323 | Returns |
| 324 | ------- |
| 325 | score : array, shape (n_samples, n_estimators) |
| 326 | Score for each estimator/task. |
| 327 | """ # noqa: E501 |
| 328 | X, _ = self._check_Xy(X, y) |
| 329 | if X.shape[-1] != len(self.estimators_): |
| 330 | raise ValueError("The number of estimators does not match X.shape[-1]") |
| 331 | |
| 332 | scoring = check_scoring(self.base_estimator, self.scoring) |
| 333 | y = _fix_auc(scoring, y) |
| 334 | |
| 335 | # For predictions/transforms the parallelization is across the data and |
| 336 | # not across the estimators to avoid memory load. |
| 337 | parallel, p_func, n_jobs = parallel_func( |
| 338 | _sl_score, |
| 339 | self.n_jobs, |
| 340 | max_jobs=X.shape[-1], |
| 341 | verbose=_verbose_safe_false(), |
| 342 | ) |
| 343 | X_splits = np.array_split(X, n_jobs, axis=-1) |
| 344 | est_splits = np.array_split(self.estimators_, n_jobs) |
| 345 | score = parallel( |
| 346 | p_func(est, scoring, x, y) for (est, x) in zip(est_splits, X_splits) |
| 347 | ) |
| 348 | |
| 349 | score = np.concatenate(score, axis=0) |
| 350 | return score |
| 351 | |
| 352 | @property |
| 353 | def classes_(self): |