3

I want to cluster some data in R with library from Python (pyclustering). I am using reticulate package to do this:

library(reticulate)
# create some random array
np <- import("numpy", convert = FALSE)
dat <- np$random$rand(100,2)
# clustering with CURE
clus_cure <- import("pyclustering.cluster.cure")
clus_res <- clus_cure$cure(dat, 2)
clus_res$get_clusters()

But it returns NULL.

Please, where is a problem?

1 Answers1

2

I think the issue is with use of pyclustering library and not with reticulate or R. As indicated in the README example, you need to run process() function on <pyclustering.cluster.cure.cure> object:

library(reticulate)
# create some random array
np <- import("numpy", convert = FALSE)
dat <- np$random$rand(10L,2L)
# clustering with CURE
clus_cure <- import("pyclustering.cluster.cure")
clus_res <- clus_cure$cure(data = dat, number_cluster=2L)
clus_res$process()
print(clus_res$get_clusters())
#> [[1]]
#> [1] 2 3 8 0 1 7 4 9
#> 
#> [[2]]
#> [1] 5 6

Also, note that you need to explicitly specify integers, where expected

dmi3kno
  • 2,943
  • 17
  • 31