MCPcopy
hub / github.com/mne-tools/mne-python / Vectorizer

Class Vectorizer

mne/decoding/transformer.py:295–396  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

293
294
295class Vectorizer(MNETransformerMixin, BaseEstimator):
296 """Transform n-dimensional array into 2D array of n_samples by n_features.
297
298 This class reshapes an n-dimensional array into an n_samples * n_features
299 array, usable by the estimators and transformers of scikit-learn.
300
301 Attributes
302 ----------
303 features_shape_ : tuple
304 Stores the original shape of data.
305
306 Examples
307 --------
308 >>> from sklearn.linear_model import LogisticRegression
309 >>> from sklearn.pipeline import make_pipeline
310 >>> from sklearn.preprocessing import StandardScaler
311 >>> clf = make_pipeline(Vectorizer(), StandardScaler(), LogisticRegression())
312 """
313
314 def fit(self, X, y=None):
315 """Store the shape of the features of X.
316
317 Parameters
318 ----------
319 X : array-like
320 The data to fit. Can be, for example a list, or an array of at
321 least 2d. The first dimension must be of length n_samples, where
322 samples are the independent samples used by the estimator
323 (e.g. n_epochs for epoched data).
324 y : None | array, shape (n_samples,)
325 Used for scikit-learn compatibility.
326
327 Returns
328 -------
329 self : instance of Vectorizer
330 Return the modified instance.
331 """
332 X = self._check_data(X, y=y, atleast_3d=False, fit=True, check_n_features=False)
333 self.features_shape_ = X.shape[1:]
334 return self
335
336 def transform(self, X):
337 """Convert given array into two dimensions.
338
339 Parameters
340 ----------
341 X : array-like
342 The data to fit. Can be, for example a list, or an array of at
343 least 2d. The first dimension must be of length n_samples, where
344 samples are the independent samples used by the estimator
345 (e.g. n_epochs for epoched data).
346
347 Returns
348 -------
349 X : array, shape (n_samples, n_features)
350 The transformed data.
351 """
352 X = self._check_data(X, atleast_3d=False)

Callers 10

test_search_light_basicFunction · 0.90
test_vectorizerFunction · 0.90
test_get_coef_multiclassFunction · 0.90
test_spatial_filter_initFunction · 0.90
50_decoding.pyFile · 0.90

Calls

no outgoing calls

Tested by 7

test_search_light_basicFunction · 0.72
test_vectorizerFunction · 0.72
test_get_coef_multiclassFunction · 0.72
test_spatial_filter_initFunction · 0.72