mne.decoding.
GeneralizationAcrossTime
(picks=None, cv=5, clf=None, train_times=None, test_times=None, predict_mode='cross-validation', scorer=None, n_jobs=1)¶Generalize across time and conditions
Creates an estimator object used to 1) fit a series of classifiers on multidimensional time-resolved data, and 2) test the ability of each classifier to generalize across other time samples.
Parameters: | picks : array-like of int | None
cv : int | object
clf : object | None
train_times : dict | None
test_times : ‘diagonal’ | dict | None, optional
predict_mode : {‘cross-validation’, ‘mean-prediction’}
scorer : object | None
n_jobs : int
|
---|---|
Attributes: | picks_ : array-like of int | None
ch_names : list, array-like, shape (n_channels,)
y_train_ : list | ndarray, shape (n_samples,)
train_times_ : dict
test_times_ : dict
cv_ : CrossValidation object
estimators_ : list of list of scikit-learn.base.BaseEstimator subclasses.
y_pred_ : list of lists of arrays of floats, shape (n_train_times, n_test_times, n_epochs, n_prediction_dims)
y_true_ : list | ndarray, shape (n_samples,)
scorer_ : object
scores_ : list of lists of float
|
See also
Notes
The function implements the method used in:
Jean-Remi King, Alexandre Gramfort, Aaron Schurger, Lionel Naccache and Stanislas Dehaene, “Two distinct dynamic modes subtend the detection of unexpected sounds”, PLoS ONE, 2014 DOI: 10.1371/journal.pone.0085791
New in version 0.9.0.
Methods
fit (epochs[, y]) |
Train a classifier on each specified time slice. |
plot ([title, vmin, vmax, tlim, ax, cmap, ...]) |
Plotting function of GeneralizationAcrossTime object |
plot_diagonal ([title, xmin, xmax, ymin, ...]) |
Plotting function of GeneralizationAcrossTime object |
plot_times (train_time[, title, xmin, xmax, ...]) |
Plotting function of GeneralizationAcrossTime object |
predict (epochs) |
Test each classifier on each specified testing time slice. |
score ([epochs, y]) |
Score Epochs |
__init__
(picks=None, cv=5, clf=None, train_times=None, test_times=None, predict_mode='cross-validation', scorer=None, n_jobs=1)¶fit
(epochs, y=None)¶Train a classifier on each specified time slice.
Note. This function sets the picks_
, ch_names
, cv_
,
y_train
, train_times_
and estimators_
attributes.
Parameters: | epochs : instance of Epochs
y : list or ndarray of int, shape (n_samples,) or None, optional
|
---|---|
Returns: | self : GeneralizationAcrossTime
|
Notes
If X and y are not C-ordered and contiguous arrays of np.float64 and X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
If X is a dense array, then the other methods will not support sparse matrices as input.
plot
(title=None, vmin=None, vmax=None, tlim=None, ax=None, cmap='RdBu_r', show=True, colorbar=True, xlabel=True, ylabel=True)¶Plotting function of GeneralizationAcrossTime object
Plot the score of each classifier at each tested time window.
Parameters: | title : str | None
vmin : float | None
vmax : float | None
tlim : ndarray, (train_min, test_max) | None
ax : object | None
cmap : str | cmap object
show : bool
colorbar : bool
xlabel : bool
ylabel : bool
|
---|---|
Returns: | fig : instance of matplotlib.figure.Figure
|
plot_diagonal
(title=None, xmin=None, xmax=None, ymin=None, ymax=None, ax=None, show=True, color=None, xlabel=True, ylabel=True, legend=True, chance=True, label='Classif. score')¶Plotting function of GeneralizationAcrossTime object
Plot each classifier score trained and tested at identical time windows.
Parameters: | title : str | None
xmin : float | None, optional
xmax : float | None, optional
ymin : float | None, optional
ymax : float | None, optional
ax : object | None
show : bool
color : str
xlabel : bool
ylabel : bool
legend : bool
chance : bool | float. Defaults to None
label : str
|
---|---|
Returns: | fig : instance of matplotlib.figure.Figure
|
plot_times
(train_time, title=None, xmin=None, xmax=None, ymin=None, ymax=None, ax=None, show=True, color=None, xlabel=True, ylabel=True, legend=True, chance=True, label='Classif. score')¶Plotting function of GeneralizationAcrossTime object
Plot the scores of the classifier trained at specific training time(s).
Parameters: | train_time : float | list or array of float
title : str | None
xmin : float | None, optional
xmax : float | None, optional
ymin : float | None, optional
ymax : float | None, optional
ax : object | None
show : bool
color : str or list of str
xlabel : bool
ylabel : bool
legend : bool
chance : bool | float.
label : str
|
---|---|
Returns: | fig : instance of matplotlib.figure.Figure
|
predict
(epochs)¶Test each classifier on each specified testing time slice.
Note
This function sets the y_pred_
and test_times_
attributes.
Parameters: | epochs : instance of Epochs
|
---|---|
Returns: | y_pred : list of lists of arrays of floats, shape (n_train_t, n_test_t, n_epochs, n_prediction_dims)
|
score
(epochs=None, y=None)¶Score Epochs
Estimate scores across trials by comparing the prediction estimated for each trial to its true value.
Calls predict()
if it has not been already.
Note. The function updates the scorer_
, scores_
, and
y_true_
attributes.
Parameters: | epochs : instance of Epochs | None, optional
y : list | ndarray, shape (n_epochs,) | None, optional
|
---|---|
Returns: | scores : list of lists of float
|