Skip to content

Commit

Permalink
Updating R code to return as best.ari, the ari observed at the optimu…
Browse files Browse the repository at this point in the history
…m; max.ari contains the best ari observed.
  • Loading branch information
kdorman committed May 15, 2024
1 parent a7e9333 commit ffce3d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/kmodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion src/kmodes_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum RETURN_SLOT {
AVERAGE_CRITERION_SLOT,
NUMBER_INITIALIZATIONS_SLOT,
BEST_RAND_SLOT,
MAX_RAND_SLOT,
AVERAGE_RAND_SLOT,
NUMBER_SLOTS,
};
Expand All @@ -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 *);
Expand Down Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down

0 comments on commit ffce3d2

Please sign in to comment.