Score predictions generated with a receptive field. This calls ``self.predict``, then masks the output of this and ``y` with ``self.valid_samples_``. Finally, it passes this to a :mod:`sklearn.metrics` scorer. Parameters ---------- X : array, shape (
(self, X, y)
| 366 | return y_pred |
| 367 | |
| 368 | def score(self, X, y): |
| 369 | """Score predictions generated with a receptive field. |
| 370 | |
| 371 | This calls ``self.predict``, then masks the output of this |
| 372 | and ``y` with ``self.valid_samples_``. Finally, it passes |
| 373 | this to a :mod:`sklearn.metrics` scorer. |
| 374 | |
| 375 | Parameters |
| 376 | ---------- |
| 377 | X : array, shape (n_times[, n_epochs], n_channels) |
| 378 | The input features for the model. |
| 379 | y : array, shape (n_times[, n_epochs][, n_outputs]) |
| 380 | Used for scikit-learn compatibility. |
| 381 | |
| 382 | Returns |
| 383 | ------- |
| 384 | scores : list of float, shape (n_outputs,) |
| 385 | The scores estimated by the model for each output (e.g. mean |
| 386 | R2 of ``predict(X)``). |
| 387 | """ |
| 388 | # Create our scoring object |
| 389 | scorer_ = _SCORERS[self.scoring] |
| 390 | |
| 391 | # Generate predictions, then reshape so we can mask time |
| 392 | X, y = self._check_dimensions(X, y, predict=True)[:2] |
| 393 | n_times, n_epochs, n_outputs = y.shape |
| 394 | y_pred = self.predict(X) |
| 395 | y_pred = y_pred[self.valid_samples_] |
| 396 | y = y[self.valid_samples_] |
| 397 | |
| 398 | # Re-vectorize and call scorer |
| 399 | y = y.reshape([-1, n_outputs], order="F") |
| 400 | y_pred = y_pred.reshape([-1, n_outputs], order="F") |
| 401 | assert y.shape == y_pred.shape |
| 402 | scores = scorer_(y, y_pred, multioutput="raw_values") |
| 403 | return scores |
| 404 | |
| 405 | def _check_dimensions(self, X, y, predict=False): |
| 406 | _validate_type(X, "array-like", "X") |