stratified_resample_data¶
- stratified_resample_data(X_train, y_train, X_test, y_test, random_state=None)[source]¶
Stratified resample data without replacement using a random state.
Reproducible resampling. Combines train and test, resamples to get the same class distribution, then returns new train and test.
Only classification labels are supported.
- Parameters:
- X_trainnp.ndarray or list of np.ndarray
Train data in a 2d or 3d ndarray or list of arrays.
- y_trainnp.ndarray
Train data labels.
- X_testnp.ndarray or list of np.ndarray
Test data in a 2d or 3d ndarray or list of arrays.
- y_testnp.ndarray
Test data labels.
- random_stateint, RandomState instance or None, default=None
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
- Returns:
- train_Xnp.ndarray or list of np.ndarray
New train data.
- train_ynp.ndarray
New train labels.
- test_Xnp.ndarray or list of np.ndarray
New test data.
- test_ynp.ndarray
New test labels.