cuml_kmeans: Run the K means clustering algorithm.

Description Usage Arguments Value Examples

View source: R/kmeans.R

Description

Run the K means clustering algorithm.

Usage

1
2
3
4
5
6
7
8
9
cuml_kmeans(
  x,
  k,
  max_iters = 300,
  tol = 0,
  init_method = c("kmeans++", "random"),
  seed = 0L,
  cuml_log_level = c("off", "critical", "error", "warn", "info", "debug", "trace")
)

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.

tol

Relative tolerance with regards to inertia to declare convergence. Default: 0 (i.e., do not use inertia-based stopping criterion).

init_method

Method for initializing the centroids. Valid methods include "kmeans++", "random", or a matrix of k rows, each row specifying the initial value of a centroid. Default: "kmeans++".

seed

Seed to the random number generator. Default: 0.

cuml_log_level

Log level within cuML library functions. Must be one of "off", "critical", "error", "warn", "info", "debug", "trace". Default: off.

Value

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

Examples

1
2
3
4
5
6
7
8
9
library(cuml)

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

print(kclust)

cuml documentation built on Sept. 21, 2021, 1:06 a.m.

Related to cuml_kmeans in cuml...