The parameter dist
allows the user to define the distance metric to be used in the neighbors computation. Although the default is the Euclidean distance, other metrics are available. This allows the computation of distances in data sets with, for instance, both nominal and numeric features. The options available for the distance functions are as follows:
- for data with only numeric features: "Manhattan", "Euclidean", "Canberra", "Chebyshev", "p-norm";
- for data with only nominal features: "Overlap";
- for dealing with both nominal and numeric features: "HEOM", "HVDM".
When the "p-norm" is selected for the dist
parameter, it is also necessary to define the value of parameter p
. The value of parameter p
sets which "p-norm" will be used. For instance, if p
is set to 1, the "1-norm" (or Manhattan distance) is used, and if p
is set to 2, the "2-norm" (or Euclidean distance) is applied.
For more details regarding the distance functions implemented in UBL package please see the package vignettes.
This function performs an under-sampling strategy based on the notion of Tomek links for imbalanced multiclass problems. Two examples form a Tomek link if they are each other closest neighbors and they have different class labels.
The under-sampling procedure can be performed in two different ways. When detected the Tomek links, the examples of both classes can be removed, or the Tomek link can be broken by removing only one of the examples (traditionally the one belonging to the majority class). This function also includes these two procedures. Moreover, it allows for the user to identify in which classes under-sampling should be applied. These two aspects are controlled by the Cl
and rem
parameters. The Cl
parameter is used to express the classes that can be under-sampled and its default is "all" (all existing classes are candidates for having examples removed). The parameter rem
indicates if the Tomek link is broken by removing both examples ("both") or by removing only the example belonging to the more populated class between the two existing in the Tomek link.
Note that the options for Cl
and rem
may "disagree". In those cases, the preference is given to the Cl
options once the user choose that specific set of classes to under-sample and not the other ones (even if the defined classes are not the larger ones). This means that, when making a decision on how many and which examples will be removed the first criteria used will be the Cl
definition .
For a better clarification of the impact of the options selected for Cl and rem parameters we now provide some possible scenarios and the expected behavior:
1) Cl
is set to one class which is neither the more nor the less frequent, and rem
is set to "maj". The expected behavior is the following:
- if a Tomek link exists connecting the largest class and another class(not included in Cl
): no example is removed;
- if a Tomek link exists connecting the larger class and the class defined in Cl
: the example from the Cl
class is removed (because the user expressly indicates that only examples from class Cl
should be removed);
2) Cl
includes two classes and rem
is set to "both". This function will do the following:
- if a Tomek link exists between an example with class in Cl
and another example with class not in Cl
, then, only the example with class in Cl
is removed;
- if the Tomek link exists between two examples with classes in Cl
, then, both are removed.
3) Cl
includes two classes and rem
is set to "maj". The behavior of this function is the following:
-if a Tomek link exists connecting two classes included in Cl
, then only the example belonging to the more populated class is removed;
-if a Tomek link exists connecting an example from a class included in Cl
and another example whose class is not in Cl
and is the largest class, then, no example is removed.