From: Benjamin Auder Date: Wed, 8 Mar 2017 21:30:16 +0000 (+0100) Subject: WER distances is a regular matrix, fix doc (weird latex error?) X-Git-Url: https://git.auder.net/variants/%24%7Bvname%7D/app_dev.php/js/current/%7B%7B?a=commitdiff_plain;h=777c4b0274c059eeb5d4bd784ef773e819a7f7a2;p=epclust.git WER distances is a regular matrix, fix doc (weird latex error?) --- diff --git a/epclust/R/clustering.R b/epclust/R/clustering.R index 92adda2..0d37c24 100644 --- a/epclust/R/clustering.R +++ b/epclust/R/clustering.R @@ -18,6 +18,7 @@ #' @param getContribs Function to retrieve contributions from initial series indices: #' \code{getContribs(indices)} outpus a contributions matrix #' @param contribs matrix of contributions (e.g. output of \code{curvesToContribs()}) +#' @param distances matrix of K1 x K1 (WER) distances between synchrones #' @inheritParams computeSynchrones #' @inheritParams claws #' @@ -77,8 +78,7 @@ clusteringTask2 = function(medoids, K2, synchrones = computeSynchrones(medoids, getRefSeries, nb_ref_curves, nb_series_per_chunk, ncores_clust, verbose, parll) distances = computeWerDists(synchrones, ncores_clust, verbose, parll) - # PAM in package 'cluster' cannot take big.matrix in input: need to cast it - medoids[ computeClusters2(distances[,],K2,verbose), ] + medoids[ computeClusters2(distances,K2,verbose), ] } #' @rdname clustering @@ -166,7 +166,7 @@ computeSynchrones = function(medoids, getRefSeries, } indices_workers = .spreadIndices(seq_len(nb_ref_curves), nb_series_per_chunk) - browser() +#browser() ignored <- if (parll) parallel::parLapply(cl, indices_workers, computeSynchronesChunk) @@ -197,7 +197,7 @@ computeSynchrones = function(medoids, getRefSeries, #' as the series in the initial dataset #' @inheritParams claws #' -#' @return A big.matrix of size K1 x K1 +#' @return A matrix of size K1 x K1 #' #' @export computeWerDists = function(synchrones, ncores_clust=1,verbose=FALSE,parll=TRUE) @@ -244,6 +244,7 @@ computeWerDists = function(synchrones, ncores_clust=1,verbose=FALSE,parll=TRUE) sqres / max(Mod(sqres)) } + # Distance between rows i and j computeDistancesIJ = function(pair) { i = pair[1] ; j = pair[2] @@ -278,7 +279,9 @@ computeWerDists = function(synchrones, ncores_clust=1,verbose=FALSE,parll=TRUE) parallel::stopCluster(cl) Xwer_dist[n,n] = 0. - Xwer_dist + distances <- Xwer_dist[,] + rm(Xwer_dist) ; gc() + distances #~small matrix K1 x K1 } # Helper function to divide indices into balanced sets