mne.decoding.Vectorizer#

class mne.decoding.Vectorizer[source]#

Transform n-dimensional array into 2D array of n_samples by n_features.

This class reshapes an n-dimensional array into an n_samples * n_features array, usable by the estimators and transformers of scikit-learn.

Attributes:
features_shape_tuple

Stores the original shape of data.

Methods

fit(X[, y])

Store the shape of the features of X.

fit_transform(X[, y])

Fit the data, then transform in one step.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

inverse_transform(X)

Transform 2D data back to its original feature shape.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Convert given array into two dimensions.

Examples

>>> from sklearn.linear_model import LogisticRegression
>>> from sklearn.pipeline import make_pipeline
>>> from sklearn.preprocessing import StandardScaler
>>> clf = make_pipeline(Vectorizer(), StandardScaler(), LogisticRegression())
fit(X, y=None)[source]#

Store the shape of the features of X.

Parameters:
Xarray_like

The data to fit. Can be, for example a list, or an array of at least 2d. The first dimension must be of length n_samples, where samples are the independent samples used by the estimator (e.g. n_epochs for epoched data).

yNone | array, shape (n_samples,)

Used for scikit-learn compatibility.

Returns:
selfinstance of Vectorizer

Return the modified instance.

fit_transform(X, y=None)[source]#

Fit the data, then transform in one step.

Parameters:
Xarray_like

The data to fit. Can be, for example a list, or an array of at least 2d. The first dimension must be of length n_samples, where samples are the independent samples used by the estimator (e.g. n_epochs for epoched data).

yNone | array, shape (n_samples,)

Used for scikit-learn compatibility.

Returns:
Xarray, shape (n_samples, -1)

The transformed data.

get_metadata_routing()[source]#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)[source]#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

inverse_transform(X)[source]#

Transform 2D data back to its original feature shape.

Parameters:
Xarray_like, shape (n_samples, n_features)

Data to be transformed back to original shape.

Returns:
Xarray

The data transformed into shape as used in fit. The first dimension is of length n_samples.

set_output(*, transform=None)[source]#

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • “polars”: Polars output

  • None: Transform configuration is unchanged

New in v1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)[source]#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X)[source]#

Convert given array into two dimensions.

Parameters:
Xarray_like

The data to fit. Can be, for example a list, or an array of at least 2d. The first dimension must be of length n_samples, where samples are the independent samples used by the estimator (e.g. n_epochs for epoched data).

Returns:
Xarray, shape (n_samples, n_features)

The transformed data.

Examples using mne.decoding.Vectorizer#

Decoding (MVPA)

Decoding (MVPA)

XDAWN Decoding From EEG data

XDAWN Decoding From EEG data

Linear classifier on sensor data with plot patterns and filters

Linear classifier on sensor data with plot patterns and filters