check_sampling_strategy(sampling_strategy, y, sampling_type, **kwargs)¶
Sampling target validation for samplers.
sampling_strategyis of consistent type and return a dictionary containing each targeted class with its corresponding number of sample. It is used in
- sampling_strategy : float, str, dict, list or callable,
Sampling information to sample the data set.
For under-sampling methods, it corresponds to the ratio defined by where and are the number of samples in the majority class after resampling and the number of samples in the minority class, respectively;
For over-sampling methods, it correspond to the ratio defined by where and are the number of samples in the minority class after resampling and the number of samples in the majority class, respectively.
floatis only available for binary classification. An error is raised for multi-class classification and with cleaning samplers.
str, specify the class targeted by the resampling. For under- and over-sampling methods, the number of samples in the different classes will be equalized. For cleaning methods, the number of samples will not be equal. Possible choices are:
'minority': resample only the minority class;
'majority': resample only the majority class;
'not minority': resample all classes but the minority class;
'not majority': resample all classes but the majority class;
'all': resample all classes;
'auto': for under-sampling methods, equivalent to
'not minority'and for over-sampling methods, equivalent to
dict, the keys correspond to the targeted classes. The values correspond to the desired number of samples for each targeted class.
dictis available for both under- and over-sampling methods. An error is raised with cleaning methods. Use a
list, the list contains the targeted classes. It used only for cleaning methods.
listis available for cleaning methods. An error is raised with under- and over-sampling methods.
When callable, function taking
yand returns a
dict. The keys correspond to the targeted classes. The values correspond to the desired number of samples for each class.
- y : ndarray, shape (n_samples,)
The target array.
- sampling_type : str,
The type of sampling. Can be either
- kwargs : dict, optional
Dictionary of additional keyword arguments to pass to
sampling_strategywhen this is a callable.
- sampling_strategy_converted : dict,
The converted and validated sampling target. Returns a dictionary with the key being the class target and the value being the desired number of samples.