powered by
Undersample a dataset by iteratively removing the observation with the lowest total distance to its neighbors of the same class.
undersample_mindist(data, cls, cls_col, m, ...)
An undersampled dataframe.
Dataset to undersample. Aside from cls_col, must be numeric.
cls_col
Class to be undersampled.
Column containing class information.
Desired number of observations after undersampling.
Additional arguments passed to dist().
dist()
setosa <- iris[iris$Species == "setosa", ] nrow(setosa) undersamp <- undersample_mindist(setosa, "setosa", "Species", 50) nrow(undersamp)
Run the code above in your browser using DataLab