Learn R Programming

ClusterR (version 1.0.1)

predict_KMeans: Prediction function for the k-means

Description

Prediction function for the k-means

Usage

predict_KMeans(data, CENTROIDS)

Arguments

data
matrix or data frame
CENTROIDS
a matrix of initial cluster centroids. The rows of the CENTROIDS matrix should be equal to the number of clusters and the columns should be equal to the columns of the data.

Value

a vector (clusters)

Details

This function takes the data and the output centroids and returns the clusters.

Examples

Run this code

data(dietary_survey_IBS)

dat = dietary_survey_IBS[, -ncol(dietary_survey_IBS)]

dat = center_scale(dat)

km = KMeans_rcpp(dat, clusters = 2, num_init = 5, max_iters = 100, initializer = 'optimal_init')

pr = predict_KMeans(dat, km$centroids)

Run the code above in your browser using DataLab