Skip to contents

Perform k-means clustering for a different combinations of indices and distances.

Usage

clustInd_kmeans(
  ind_data,
  vars_combinations,
  dist_vector = c("euclidean", "mahalanobis"),
  n_cluster = 2,
  init = "random",
  true_labels = NULL,
  n_cores = 1
)

Arguments

ind_data

Dataframe containing indices applied to the original data and its first and second derivatives. See generate_indices.

vars_combinations

list containing one or more combinations of indices in ind_data. If it is non-named, the names of the variables are set to vars1, ..., varsk, where k is the number of elements in vars_combinations.

dist_vector

Atomic vector of distance metrics. The possible values are, "euclidean", "mahalanobis" or both.

n_cluster

Number of clusters to create.

init

Centroids initialization meathod. It can be "random" or "kmeanspp".

true_labels

Vector of true labels for validation. (if it is not known true_labels is set to NULL)

n_cores

Number of cores to do parallel computation. 1 by default, which mean no parallel execution.

Value

A list containing hierarchical clustering results for each configuration

A list containing kmeans clustering results for each configuration

Examples

vars1 <- c("dtaEI", "dtaMEI")
vars2 <- c("dtaHI", "dtaMHI")
data <- ehymet::sim_model_ex1()
data_ind <- generate_indices(data)
clustInd_kmeans(data_ind, list(vars1, vars2))
#> $kmeans_euclidean_dtaEIdtaMEI
#> $kmeans_euclidean_dtaEIdtaMEI$cluster
#>   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
#>   2   2   2   2   2   2   1   1   2   2   2   2   2   2   2   1   1   1   1   2 
#>  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 
#>   1   2   2   1   2   1   1   2   1   2   1   2   1   2   2   2   1   2   2   2 
#>  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60 
#>   2   2   2   2   1   2   2   2   1   2   1   1   2   1   1   1   1   1   2   1 
#>  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80 
#>   1   1   1   1   1   1   1   1   1   1   1   1   2   1   1   1   1   1   1   2 
#>  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 
#>   1   1   1   1   2   1   1   1   1   1   1   1   2   1   1   1   1   1   1   2 
#> 
#> $kmeans_euclidean_dtaEIdtaMEI$internal_metrics
#> $kmeans_euclidean_dtaEIdtaMEI$internal_metrics$davies_bouldin
#> [1] 0.6352604
#> 
#> $kmeans_euclidean_dtaEIdtaMEI$internal_metrics$dunn
#> [1] 0.05614307
#> 
#> $kmeans_euclidean_dtaEIdtaMEI$internal_metrics$silhouette
#> [1] 0.5431761
#> 
#> $kmeans_euclidean_dtaEIdtaMEI$internal_metrics$infomax
#> [1] 0.9765005
#> 
#> 
#> $kmeans_euclidean_dtaEIdtaMEI$time
#> [1] 0.002989054
#> 
#> 
#> $kmeans_euclidean_dtaHIdtaMHI
#> $kmeans_euclidean_dtaHIdtaMHI$cluster
#>   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
#>   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
#>  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 
#>   2   1   1   1   1   1   1   1   1   1   2   1   2   1   1   1   2   1   1   1 
#>  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60 
#>   1   1   1   1   2   1   1   1   1   1   2   2   1   2   1   2   2   2   1   2 
#>  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80 
#>   2   2   2   1   2   2   2   2   2   1   2   1   1   2   1   2   2   1   2   1 
#>  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 
#>   2   2   2   1   1   2   2   2   2   2   1   2   1   2   2   2   1   2   2   1 
#> 
#> $kmeans_euclidean_dtaHIdtaMHI$internal_metrics
#> $kmeans_euclidean_dtaHIdtaMHI$internal_metrics$davies_bouldin
#> [1] 0.6362897
#> 
#> $kmeans_euclidean_dtaHIdtaMHI$internal_metrics$dunn
#> [1] 0.07705545
#> 
#> $kmeans_euclidean_dtaHIdtaMHI$internal_metrics$silhouette
#> [1] 0.5440438
#> 
#> $kmeans_euclidean_dtaHIdtaMHI$internal_metrics$infomax
#> [1] 0.9647995
#> 
#> 
#> $kmeans_euclidean_dtaHIdtaMHI$time
#> [1] 0.002812386
#> 
#> 
#> $kmeans_mahalanobis_dtaEIdtaMEI
#> $kmeans_mahalanobis_dtaEIdtaMEI$cluster
#>   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
#>   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
#>  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 
#>   1   2   2   2   2   2   2   2   2   2   1   2   1   2   2   2   1   2   2   2 
#>  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60 
#>   2   2   2   2   1   2   2   2   2   2   1   1   2   1   2   1   1   1   2   1 
#>  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80 
#>   1   1   1   2   1   1   1   1   1   2   1   2   2   1   2   1   1   2   1   2 
#>  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 
#>   1   1   1   2   2   1   1   2   1   1   2   1   2   1   1   1   2   1   1   2 
#> 
#> $kmeans_mahalanobis_dtaEIdtaMEI$internal_metrics
#> $kmeans_mahalanobis_dtaEIdtaMEI$internal_metrics$davies_bouldin
#> [1] 0.6094513
#> 
#> $kmeans_mahalanobis_dtaEIdtaMEI$internal_metrics$dunn
#> [1] 0.05358602
#> 
#> $kmeans_mahalanobis_dtaEIdtaMEI$internal_metrics$silhouette
#> [1] 0.5534391
#> 
#> $kmeans_mahalanobis_dtaEIdtaMEI$internal_metrics$infomax
#> [1] 0.958042
#> 
#> 
#> $kmeans_mahalanobis_dtaEIdtaMEI$time
#> [1] 0.003039837
#> 
#> 
#> $kmeans_mahalanobis_dtaHIdtaMHI
#> $kmeans_mahalanobis_dtaHIdtaMHI$cluster
#>   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
#>   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
#>  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 
#>   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
#>  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60 
#>   1   1   1   1   1   1   1   1   1   1   1   2   1   1   1   1   2   1   1   1 
#>  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80 
#>   1   1   1   1   1   1   2   1   1   1   1   1   1   2   1   2   1   1   1   1 
#>  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 
#>   2   1   2   1   1   1   2   1   1   1   1   1   1   1   2   1   1   1   1   1 
#> 
#> $kmeans_mahalanobis_dtaHIdtaMHI$internal_metrics
#> $kmeans_mahalanobis_dtaHIdtaMHI$internal_metrics$davies_bouldin
#> [1] 0.5811685
#> 
#> $kmeans_mahalanobis_dtaHIdtaMHI$internal_metrics$dunn
#> [1] 0.09571253
#> 
#> $kmeans_mahalanobis_dtaHIdtaMHI$internal_metrics$silhouette
#> [1] 0.5719493
#> 
#> $kmeans_mahalanobis_dtaHIdtaMHI$internal_metrics$infomax
#> [1] 0.4364698
#> 
#> 
#> $kmeans_mahalanobis_dtaHIdtaMHI$time
#> [1] 0.003018618
#> 
#>