Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify step.pattern parameter in compare_clustering_configs #59

Closed
marc-heinl opened this issue Apr 13, 2022 · 3 comments
Closed

Specify step.pattern parameter in compare_clustering_configs #59

marc-heinl opened this issue Apr 13, 2022 · 3 comments

Comments

@marc-heinl
Copy link

marc-heinl commented Apr 13, 2022

Hello,

I would like to use the compare_clusterings() function with a pre-defined clustering setting. Therefore I use compare_cluster_configs respectively pdc_configs with dtw_basic as distance measure. To change step.pattern to dtw::symmetric1 for cluster-comparison I already tried to set the parameter within the dtw_basic list config e.g. dtw_basic = list(step.pattern = dtw::symmetric1)
I also tried dtw_basic = list(step.pattern = "dtw::symmetric1") and dtw_basic = list(step.pattern = 1)
None of this seems to work and I get different errors for each config.

If nothing is set and default step.pattern is used everything works fine.

I would appreciate any kind of help.

Here a clipping of my code:

daily_widw <- round(0.05*length(typedays_time_series))

clustering_cfg_typedays <- compare_clusterings_configs( 
  types = c("p", "h"),  
  k = 3L:6L,
  controls = list( 
    partitional = partitional_control(iter.max = 50L, symmetric = TRUE, nrep = 3),
    hierarchical = hierarchical_control(method='complete', symmetric = TRUE)    #complete linkage 
  ),
  distances = pdc_configs( 
    type ="distance",
    sbd = list(norm = "L2"),
    sbd = list(norm = "L2", znorm=TRUE),
    L2 = list(norm = "L2"),
    #5%
    dtw_basic = list(step.pattern = dtw::symmetric1, windows.size = daily_widw, norm = "L2"),
    #10%
    dtw_basic = list(step.pattern = dtw::symmetric1, windows.size = 2*daily_widw, norm = "L2"),
    share.config = c("p", "h")
  ),
  centroids = pdc_configs( 
    type = "centroid", 
    partitional = list(
      mean = list(norm = "L2"),
      pam = list(norm = "L2"),
      #5% windows for dba
      dba = list( windows.size = daily_widw, norm = "L2"),
      #10% windows for dba
      dba = list( windows.size = 2*daily_widw, norm = "L2"),
      shape = list(norm = "L2")
    ),
    hierarchical = list(
      default = list()
    )
  )
)
@asardaes
Copy link
Owner

Hm, it seems that's actually not possible at the moment... I never thought about that case. I think the best option would be to wrap the patterns in a list like this:

pdc_configs(
    type = "distance",
    dtw_basic = list(
        norm = c("L1", "L2"), # example
        step.pattern = list(dtw::symmetric1, dtw::symmetric2)
    )
)

But the current version of compare_clusterings will not be able to unlist that correctly, so I'll have to change the code a bit.

asardaes added a commit that referenced this issue Apr 13, 2022
Maybe unlist once before calling tsclust_args.
@asardaes
Copy link
Owner

I'll push an update to CRAN shortly, but if you can install from github, give it a try with list as I mentioned.

@marc-heinl
Copy link
Author

marc-heinl commented Apr 16, 2022

I tried the new implemented functionallity with the list wrapper for step.pattern specification with dtw::symmetric1 and everything works just fine.
Thank you again for the fast adjustment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants