| ncl | R Documentation |
Under-samples the majority classes by cleaning noisy observations and observations that pollute the neighborhood of minority class observations.
ncl(df, var, neighbors = 3, distance = "euclidean", threshold_clean = 0.5)
df |
data.frame or tibble. Must have 1 factor variable and remaining numeric variables. |
var |
Character, name of variable containing factor variable. |
neighbors |
An integer. Number of nearest neighbor that are used to
decide whether an observation is removed. Defaults to |
distance |
A character string specifying the distance metric used for
nearest neighbor calculations, defaulting to
The probability divergences are meaningful for compositional predictors such as proportions or counts normalized per observation, and are generally not appropriate for standardized predictors. |
threshold_clean |
A numeric. Majority classes are only cleaned around
minority class observations when their size is greater than
|
The Neighborhood Cleaning Rule (NCL) is a cleaning method that combines two
passes over the data. First, it applies the Edited Nearest Neighbors rule,
removing majority class observations whose class differs from the majority of
their neighbors nearest neighbors. Second, for each minority class
observation that is itself misclassified by its neighbors, the majority class
observations among those neighbors are removed. Compared to Edited Nearest
Neighbors, this focuses the cleaning on the neighborhoods of minority class
observations.
The smallest class is treated as the minority class. Only majority classes
larger than threshold_clean times the size of the minority class are
cleaned in the second pass.
All columns used in this function must be numeric with no missing data.
A data.frame or tibble, depending on type of df.
Laurikkala, J. (2001). Improving identification of difficult small classes by balancing class distribution. In Conference on Artificial Intelligence in Medicine in Europe (pp. 63-66). Springer.
step_ncl() for step function of this method
Other Direct Implementations:
adasyn(),
bsmote(),
cluster_centroids(),
cnn(),
enn(),
instance_hardness(),
kmeans_smote(),
nearmiss(),
oss(),
rose(),
smogn(),
smote(),
smoten(),
smotenc(),
svmsmote(),
tomek()
circle_numeric <- circle_example[, c("x", "y", "class")]
res <- ncl(circle_numeric, var = "class")
res <- ncl(circle_numeric, var = "class", neighbors = 5)
res <- ncl(circle_numeric, var = "class", distance = "manhattan")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.