find_clusters | R Documentation |
Finds the cluster and thus the EMM states for observations.
## S4 method for signature 'tNN,matrix'
find_clusters(x, newdata, match_cluster=c("exact", "nn"), dist = FALSE)
x |
an |
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). |
Returns the name of the matching clusters/states or a data.frame with
columns "state" and "dist" if dist=TRUE
.
EMM
and tNN
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.