improve/fix comments - TODO: debug examples, CSV and after
[epclust.git] / epclust / R / clustering.R
index a8f1d3e..1774b19 100644 (file)
@@ -1,14 +1,14 @@
 #' Two-stage clustering, within one task (see \code{claws()})
 #'
 #' \code{clusteringTask1()} runs one full stage-1 task, which consists in iterated
-#' stage 1 clustering on nb_curves / ntasks energy contributions, computed through
+#' clustering on nb_curves / ntasks energy contributions, computed through
 #' discrete wavelets coefficients.
 #' \code{clusteringTask2()} runs a full stage-2 task, which consists in WER distances
 #' computations between medoids (indices) output from stage 1, before applying
 #' the second clustering algorithm on the distances matrix.
 #'
 #' @param getContribs Function to retrieve contributions from initial series indices:
-#'   \code{getContribs(indices)} outputs a contributions matrix
+#'   \code{getContribs(indices)} outputs a contributions matrix, in columns
 #' @inheritParams claws
 #' @inheritParams computeSynchrones
 #' @inheritParams computeWerDists
@@ -23,12 +23,16 @@ NULL
 #' @rdname clustering
 #' @export
 clusteringTask1 <- function(indices, getContribs, K1, algoClust1, nb_items_clust,
-       ncores_clust=1, verbose=FALSE, parll=TRUE)
+       ncores_clust=3, verbose=FALSE, parll=TRUE)
 {
        if (parll)
        {
                # outfile=="" to see stderr/stdout on terminal
-               cl <- parallel::makeCluster(ncores_clust, outfile = "")
+               cl <-
+                       if (verbose)
+                               parallel::makeCluster(ncores_clust, outfile = "")
+                       else
+                               parallel::makeCluster(ncores_clust)
                parallel::clusterExport(cl, c("getContribs","K1","verbose"), envir=environment())
        }
        # Iterate clustering algorithm 1 until K1 medoids are found
@@ -62,7 +66,7 @@ clusteringTask1 <- function(indices, getContribs, K1, algoClust1, nb_items_clust
 #' @rdname clustering
 #' @export
 clusteringTask2 <- function(indices, getSeries, K2, algoClust2, nb_series_per_chunk,
-       smooth_lvl, nvoice, nbytes, endian, ncores_clust=1, verbose=FALSE, parll=TRUE)
+       smooth_lvl, nvoice, nbytes, endian, ncores_clust=3, verbose=FALSE, parll=TRUE)
 {
        if (verbose)
                cat(paste("*** Clustering task 2 on ",length(indices)," medoids\n", sep=""))