Skip to contents

Returns the index of the nearest centroid to x without updating the model.

Usage

kmeans_stream_predict(model, x)

Arguments

model

a streaming k-means model created by kmeans_stream_new

x

a numeric vector of length d

Value

integer, the cluster assignment for x (1-indexed)

Examples

model <- kmeans_stream_new(k = 2L, d = 2L)
kmeans_stream_update(model, c(0.0, 0.0))
#> [1] 1
kmeans_stream_update(model, c(5.0, 5.0))
#> [1] 2
kmeans_stream_predict(model, c(0.1, 0.1))
#> [1] 1