| predict.stdbscan | R Documentation |
Assigns each new observation to an existing cluster from a fitted stdbscan
object, or marks it as noise if it falls outside any cluster.
## S3 method for class 'stdbscan'
predict(object, data, newdata, ...)
object |
An object of class |
data |
matrix. The data set used to create the clustering object. |
newdata |
matrix. New data points for which the cluster membership should be predicted. The data must be in the same format as the input data. |
... |
Additional arguments are passed on to |
An integer vector of cluster labels, matching the labels of the input
stdbscan object.
data(geolife_traj)
geolife_traj$date_time <- as.POSIXct(
paste(geolife_traj$date, geolife_traj$time),
format = "%Y-%m-%d %H:%M:%S",
tz = "GMT"
)
geolife_traj$t <- as.numeric(
geolife_traj$date_time - min(geolife_traj$date_time)
)
data <- cbind(geolife_traj$x, geolife_traj$y, geolife_traj$t)
res <- st_dbscan(
data = data,
eps_spatial = 3,
eps_temporal = 30,
min_pts = 5
)
newdata <- cbind(
c(440160, 440165, 440144, 440130, 440160),
c(4428129, 4428135, 4428120, 4428123, 4428122),
c(4617, 4620, 4629, 4635, 4640)
)
predict(res, data, newdata)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.