pyriemann.datasets.RandomOverSampler¶
- class pyriemann.datasets.RandomOverSampler(metric='riemann', sampling_strategy='auto', random_state=None, n_jobs=1)¶
Random over-sampling for SPD/HPD matrices.
For each class, output SPD/HPD matrices are interpolated along the geodesic between input SPD/HPD matrices [1].
- Parameters:
- metricstring, default=”riemann”
Metric used for SPD/HPD matrices interpolation (see
pyriemann.utils.geodesic.geodesic()).- sampling_strategystr, default=”auto”
Specify the class targeted by the resampling. The number of matrices in the different classes will be equalized. Possible choices are:
“minority”: resample only the minority class;
“not minority”: resample all classes but the minority class;
“not majority”: resample all classes but the majority class;
“all”: resample all classes;
“auto”: equivalent to “not majority”.
- random_stateint | RandomState instance | None, default=None
Pass an int for reproducible output across multiple function calls.
- n_jobsint, default=1
Number of jobs to use for the computation. This works by computing each of the class resampling in parallel. If -1 all CPUs are used. If 1 is given, no parallel computing code is used at all, which is useful for debugging. For n_jobs below -1, (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used.
Notes
Added in version 0.10.
References
[1]Data augmentation in Riemannian space for brain-computer interfaces E. Kalunga, S. Chevallier and Q. Barthélemy. ICML Workshop on Statistics, Machine Learning and Neuroscience, 2015.
- __init__(metric='riemann', sampling_strategy='auto', random_state=None, n_jobs=1)¶
Init.
- fit(X, y)¶
Check parameters of the sampler.
You should use
fit_resamplein all cases.- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD/HPD matrices.
- yndarray, shape (n_matrices,)
Labels for each matrix.
- Returns:
- selfobject
Return the instance itself.
- fit_resample(X, y)¶
Resample the matrices.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD/HPD matrices.
- yndarray, shape (n_matrices,)
Labels for each matrix.
- Returns:
- X_resampledndarray, shape (n_matrices_new, n_channels, n_channels)
Set of resampled SPD/HPD matrices.
- y_resampledndarray, shape (n_matrices_new,)
Labels for each resampled matrix.
- get_metadata_routing()¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)¶
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.
- set_params(**params)¶
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.