imblearn.under_sampling.TomekLinks.is_tomek¶
-
static
TomekLinks.
is_tomek
(y, nn_index, class_type)[source]¶ Detect if samples are Tomek’s link.
More precisely, it uses the target vector and the first neighbour of every sample point and looks for Tomek pairs. Returning a boolean vector with True for majority Tomek links.
- Parameters
- yndarray of shape (n_samples,)
Target vector of the data set, necessary to keep track of whether a sample belongs to minority or not.
- nn_indexndarray of shape (len(y),)
The index of the closes nearest neighbour to a sample point.
- class_typeint or str
The label of the minority class.
- Returns
- is_tomekndarray of shape (len(y), )
Boolean vector on len( # samples ), with True for majority samples that are Tomek links.