KMEANS: KMEANS

Description Usage Arguments Value See Also Examples

View source: R/kmeans.R

Description

Generates a K-means clustering of a given feature matrix, with K cluster centers. K-means is a common non-probabilistic clustering method, useful when data can be fit to circular clusters.

Usage

1
KMEANS(data_matrix, K)

Arguments

data_matrix

An N x M matrix, containing N rows (observations) and M columns (data features)

K

A positive integer describing the number of clusters the clustering should produce.

Value

A list containing the following results:

cluster

a vector of length N containing the cluster ids of each observation. Cluster ids are positive integers from 1:K inclusive.

centers

a matrix of cluster centers, with K rows, and M columns.

withinss

a vector of length K, containing within-cluster sums of squares for each cluster.

tot.withinss

the total within-cluster sum of squares

size

a vector of length K, containing the number of points in each cluster.

See Also

stats::kmeans for a more robust implementation.

Examples

1
2
# Cluster the iris data set into three clusters:
KMEANS(iris[1:4], K=3)

ChrisKeefe/UnsupLP1 documentation built on Oct. 8, 2020, 5:37 a.m.