ctype = "absolute"
getContribs = function(indices) curvesToContribs(series[,indices],wf,ctype)
require("cluster", quietly=TRUE)
- browser()
- algoClust1 = function(contribs,K) cluster::pam(contribs,K,diss=FALSE)$id.med
+ algoClust1 = function(contribs,K) cluster::pam(t(contribs),K,diss=FALSE)$id.med
indices1 = clusteringTask1(1:n, getContribs, K1, algoClust1, 75, verbose=TRUE, parll=FALSE)
medoids_K1 = getSeries(indices1)
s = lapply( seq_len(K1), function(i) x^(1+i/30)*cos(x+i) )
series = matrix(nrow=L, ncol=n)
for (i in seq_len(n))
- series[i,] = s[[I(i,K1)]] + rnorm(L,sd=0.01)
+ series[,i] = s[[I(i,K1)]] + rnorm(L,sd=0.01)
getRefSeries = function(indices) {
indices = indices[indices <= n]
if (length(indices)>0) series[,indices] else NULL
}
# Artificially simulate 60 medoids - perfect situation, all equal to one of the refs
medoids_K1 = bigmemory::as.big.matrix( sapply( 1:K1, function(i) s[[I(i,K1)]] ) )
- medoids_K2 = clusteringTask2(medoids_K1, K2, getRefSeries, n, 75, verbose=TRUE, parll=FALSE)
+ algoClust2 = function(dists,K) cluster::pam(dists,K,diss=TRUE)$id.med
+ medoids_K2 = clusteringTask2(medoids_K1, K2, algoClust2, getRefSeries,
+ n, 75, sync_mean=TRUE, verbose=TRUE, parll=FALSE)
expect_equal(dim(medoids_K2), c(L,K2))
# Not easy to evaluate result: at least we expect it to be better than random selection of