diff --git a/R/kmodes.R b/R/kmodes.R index 524f26f..5d62fe7 100644 --- a/R/kmodes.R +++ b/R/kmodes.R @@ -62,7 +62,9 @@ #' \item average.criterion - The average objective function achieved across #' multiple initializations. #' \item number.initializations - The number of initializations performed. -#' \item best.ari - If true clusters provided, then the best achieved ARI, +#' \item best.ari - If true clusters provided, then the achieved ARI, from +#' the best solution, as measured by the objective function. +#' \item max.ari - If true clusters provided, then the maximum achieved ARI, #' perhaps not from the best solution, as measured by the objective function. #' \item average.ari - If true clusters provided, then the average ARI achieved #' across all initializations. diff --git a/src/kmodes_r.c b/src/kmodes_r.c index e3acbda..25096bf 100644 --- a/src/kmodes_r.c +++ b/src/kmodes_r.c @@ -19,6 +19,7 @@ enum RETURN_SLOT { AVERAGE_CRITERION_SLOT, NUMBER_INITIALIZATIONS_SLOT, BEST_RAND_SLOT, + MAX_RAND_SLOT, AVERAGE_RAND_SLOT, NUMBER_SLOTS, }; @@ -28,7 +29,7 @@ char const *slot_names[NUMBER_SLOTS] = { "cluster.sizes", "partition", "modes", "average.criterion", "number.initializations", - "best.ari", "average.ari" + "best.ari", "max.ari", "average.ari" }; int load_data(data *dat, options *opt, SEXP data_r, int *); @@ -281,12 +282,16 @@ SEXP run_kmodes_r( SEXP data_r, ScalarInteger(dat->n_init)); if (opt->simulate || opt->true_cluster) { SET_VECTOR_ELT(return_list, BEST_RAND_SLOT, + ScalarReal(dat->best_rand_at_opt)); + SET_VECTOR_ELT(return_list, MAX_RAND_SLOT, ScalarReal(dat->best_rand)); SET_VECTOR_ELT(return_list, AVERAGE_RAND_SLOT, ScalarReal(dat->avg_ar)); } else { SET_VECTOR_ELT(return_list, BEST_RAND_SLOT, ScalarReal(NA_REAL)); + SET_VECTOR_ELT(return_list, MAX_RAND_SLOT, + ScalarReal(NA_REAL)); SET_VECTOR_ELT(return_list, AVERAGE_RAND_SLOT, ScalarReal(NA_REAL)); } @@ -297,6 +302,8 @@ SEXP run_kmodes_r( SEXP data_r, ScalarInteger(NA_INTEGER)); SET_VECTOR_ELT(return_list, BEST_RAND_SLOT, ScalarReal(NA_REAL)); + SET_VECTOR_ELT(return_list, MAX_RAND_SLOT, + ScalarReal(NA_REAL)); SET_VECTOR_ELT(return_list, AVERAGE_RAND_SLOT, ScalarReal(NA_REAL)); }