imblearn.utils.check_ratio

imblearn.utils.check_ratio(ratio, y, sampling_type, **kwargs)[source][source]

DEPRECATED: imblearn.utils.check_ratio was deprecated in favor of imblearn.utils.check_sampling_strategy in 0.4. It will be removed in 0.6.

Sampling target validation for samplers.

Checks ratio for consistent type and return a dictionary containing each targeted class with its corresponding number of sample.

Deprecated since version 0.4: This function is deprecated in favor of imblearn.utils.check_sampling_strategy. It will be removed in 0.6.

Parameters:
ratio : str, dict or callable,

Ratio to use for resampling the data set.

  • If str, has to be one of: (i) 'minority': resample the minority class; (ii) 'majority': resample the majority class, (iii) 'not minority': resample all classes apart of the minority class, (iv) 'all': resample all classes, and (v) 'auto': correspond to 'all' with for over-sampling methods and 'not minority' for under-sampling methods. The classes targeted will be over-sampled or under-sampled to achieve an equal number of sample with the majority or minority class.
  • If dict, the keys correspond to the targeted classes. The values correspond to the desired number of samples.
  • If callable, function taking y and returns a dict. The keys correspond to the targeted classes. The values correspond to the desired number of samples.
y : ndarray, shape (n_samples,)

The target array.

sampling_type : str,

The type of sampling. Can be either 'over-sampling' or 'under-sampling'.

kwargs : dict, optional

Dictionary of additional keyword arguments to pass to ratio.

Returns:
ratio_converted : dict,

The converted and validated ratio. Returns a dictionary with the key being the class target and the value being the desired number of samples.