powered by
Undersample a dataset by hierarchical clustering.
undersample_hclust(data, cls, cls_col, m, k = 5, h = NA, ...)
Undersampled dataframe containing only cls.
cls
Dataset to be undersampled.
Majority class that will be undersampled.
Column in data containing class memberships.
Number of samples in undersampled dataset.
Number of clusters to derive from clustering.
Height at which to cut the clustering tree. k must be NA for this to be used.
k
NA
Additional arguments passed to dist().
dist()
table(iris$Species) undersamp <- undersample_hclust(iris, "setosa", "Species", 15) nrow(undersamp)
Run the code above in your browser using DataLab