undersample_kmeans {scutr}R Documentation

Undersample a dataset by kmeans clustering.

Description

Undersample a dataset by kmeans clustering.

Usage

undersample_kmeans(data, cls, cls_col, m, k = 5, ...)

Arguments

data

Dataset to be undersampled.

cls

Class to be undersampled.

cls_col

Column containing class information.

m

Number of samples in undersampled dataset.

k

Number of centers in clustering.

...

Additional arguments passed to kmeans()

Value

The undersampled dataframe containing only instances of cls.

Examples

table(iris$Species)
undersamp <- undersample_kmeans(iris, "setosa", "Species", 15)
nrow(undersamp)

[Package scutr version 0.2.0 Index]