find_clusters {rEMM}R Documentation

Find the EMM State/Cluster for an Observation

Description

Finds the cluster and thus the EMM states for observations.

Usage

## S4 method for signature 'tNN,matrix'
find_clusters(x, newdata, match_cluster=c("exact", "nn"), dist = FALSE)

Arguments

x

an EMM object.

newdata

a matrix/data.frame with observations.

match_cluster

find exact or nearest neighbor (nn) cluster/state. If a number is supplied then the threshold times this number is used for exact matching.

dist

also report the distance to the chosen cluster/state (as a data.frame).

Value

Returns the name of the matching clusters/states or a data.frame with columns "state" and "dist" if dist=TRUE.

See Also

EMM and tNN

Examples

data("EMMTraffic")
emm <- EMM(measure="eJaccard", threshold=0.2)
emm <- build(emm, EMMTraffic)

find_clusters(emm, EMMTraffic)
find_clusters(emm, EMMTraffic, dist=TRUE)

## add noise to the data 
set.seed(1234)
newdata <- sapply(EMMTraffic, jitter, amount=15)
## default is exact match
find_clusters(emm, newdata, dist=TRUE)
## match with nearest neighbor
find_clusters(emm, newdata, match_cluster="nn", dist=TRUE)
## exact match only if within .5 times threshold
find_clusters(emm, newdata, match_cluster=.5, dist=TRUE)
## exact match only if within 2 times threshold
find_clusters(emm, newdata, match_cluster=2, dist=TRUE)

[Package rEMM version 1.2.1 Index]