Learn R Programming

cuml4r (version 0.1.0)

cuml_kmeans: Run the K means clustering algorithm.

Description

Run the K means clustering algorithm.

Usage

cuml_kmeans(x, k, max_iters = 300)

Arguments

x

The input matrix or dataframe. Each data point should be a row and should consist of numeric values only.

k

The number of clusters.

max_iters

Maximum number of iterations (default: 300).

Value

A list containing the cluster assignments and the centroid of each cluster. Each centroid will be a column within the `centroids` matrix.

Examples

Run this code
# NOT RUN {
library(cuml4r)

kclust <- cuml_kmeans(
  iris[, which(names(iris) != "Species")],
  k = 3,
  max_iters = 100
)

print(kclust)
# }

Run the code above in your browser using DataLab