0

I am doing a time-series clustering on a large dataset (3000 time-series, with > 50 points each). Thus, I was wondering if once I have finished the analysis, it would be possible to:

  • export the model so that I can cluster new series swiftly.
  • export the "centroids" so that I can use them as the template for matching new series.

A simple MRE could look like this

my_matrix <- matrix(rnorm(1000), 100, 10)
k <- 5
clustering <- tsclust(my_matrix , k = k, trace = T)
# somehow saveRDS(clustering)

# new series coming

y <- rnorm(10)
my_clusters <- loadRDS(clustering)
# Somehow clusternew(y, my_clusters)

Thank you, S

Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98
Santi
  • 368
  • 2
  • 15
  • 1
    You can use `saveRDS()` to save a single R object and `readRDS()` to load it into your workspace. – Darren Tsai Aug 15 '20 at 08:50
  • Yes, I know and I tried to include it in the example. However, if I do `saveRDS(clustering); readRDS(clustering) %>% predict(., new_data)`, then the object is really big (~100 Mb) because it takes with it the whole dataset. That is why I was wondering if it was possible to get only the centroids. – Santi Aug 15 '20 at 11:17
  • You can, just use `clustering@centroids`. – Alexis Mar 26 '21 at 21:05

0 Answers0