Skip to content

Commit

Permalink
fixes the issue in #54
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampros committed Jun 16, 2024
1 parent 414a146 commit d36fc17
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 18 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ClusterR
Type: Package
Title: Gaussian Mixture Models, K-Means, Mini-Batch-Kmeans, K-Medoids and Affinity Propagation Clustering
Version: 1.3.2
Date: 2023-12-04
Version: 1.3.3
Date: 2024-06-16
Authors@R: c( person(given = "Lampros", family = "Mouselimis", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "https://orcid.org/0000-0002-8024-1546")), person(given = "Conrad", family = "Sanderson", role = "cph", comment = "Author of the C++ Armadillo library"), person(given = "Ryan", family = "Curtin", role = "cph", comment = "Author of the C++ Armadillo library"), person(given = "Siddharth", family = "Agrawal", role = "cph", comment = "Author of the C code of the Mini-Batch-Kmeans algorithm (https://github.com/siddharth-agrawal/Mini-Batch-K-Means)"), person(given = "Brendan", family = "Frey", email = "[email protected]", role = "cph", comment = "Author of the matlab code of the Affinity propagation algorithm (for commercial use please contact the author of the matlab code)"), person(given = "Delbert", family = "Dueck", role = "cph", comment = "Author of the matlab code of the Affinity propagation algorithm"), person(given = "Vitalie", family = "Spinu", email = "[email protected]", role = "ctb", comment = c(Github = "Github Contributor")) )
Maintainer: Lampros Mouselimis <[email protected]>
BugReports: https://github.com/mlampros/ClusterR/issues
Expand Down Expand Up @@ -32,4 +32,4 @@ Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## Cluster 1.3.3

* I fixed an issue related to the *R_NilValue* of the *'KMEANS_rcpp()'* Rcpp function in the *src/export_inst_folder_headers.cpp* file. I mistakenly used as input the *R_NilValue* whereas I should have used the *CENTROIDS* argument (see issue: https://github.com/mlampros/ClusterR/issues/54)


## Cluster 1.3.2

* I've fixed the CRAN *warning: format specifies type 'double' but the argument has type 'int''* in the following files & lines by replacing the `%g` expression with `%d`:
Expand Down
79 changes: 64 additions & 15 deletions src/export_inst_folder_headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,32 @@ arma::mat SCALE(arma::mat data, bool mean_center = true, bool sd_scale = true) {
//

// [[Rcpp::export]]
Rcpp::List KMEANS_rcpp(arma::mat& data, int clusters, int num_init = 1, int max_iters = 200, std::string initializer = "kmeans++", bool fuzzy = false, bool verbose = false,

Rcpp::Nullable<Rcpp::NumericMatrix> CENTROIDS = R_NilValue, double tol = 1e-4, double eps = 1.0e-6, double tol_optimal_init = 0.5, int seed = 1) {

Rcpp::List KMEANS_rcpp(arma::mat& data,
int clusters,
int num_init = 1,
int max_iters = 200,
std::string initializer = "kmeans++",
bool fuzzy = false,
bool verbose = false,
Rcpp::Nullable<Rcpp::NumericMatrix> CENTROIDS = R_NilValue,
double tol = 1e-4,
double eps = 1.0e-6,
double tol_optimal_init = 0.5,
int seed = 1) {
ClustHeader CRH;

return CRH.KMEANS_rcpp(data, clusters, num_init, max_iters, initializer, fuzzy, verbose, R_NilValue, tol, eps, tol_optimal_init, seed);
return CRH.KMEANS_rcpp(data,
clusters,
num_init,
max_iters,
initializer,
fuzzy,
verbose,
CENTROIDS,
tol,
eps,
tol_optimal_init,
seed);
}


Expand All @@ -81,13 +100,22 @@ Rcpp::List KMEANS_rcpp(arma::mat& data, int clusters, int num_init = 1, int max_
//

// [[Rcpp::export]]
arma::mat KMEANS_arma(arma::mat& data, int clusters, int n_iter, bool verbose, std::string seed_mode = "random_subset",

Rcpp::Nullable<Rcpp::NumericMatrix> CENTROIDS = R_NilValue, int seed = 1) {

arma::mat KMEANS_arma(arma::mat& data,
int clusters,
int n_iter,
bool verbose,
std::string seed_mode = "random_subset",
Rcpp::Nullable<Rcpp::NumericMatrix> CENTROIDS = R_NilValue,
int seed = 1) {
ClustHeader CRH;

return CRH.KMEANS_arma(data, clusters, n_iter, verbose, seed_mode, CENTROIDS, seed);
return CRH.KMEANS_arma(data,
clusters,
n_iter,
verbose,
seed_mode,
CENTROIDS,
seed);
}


Expand Down Expand Up @@ -159,13 +187,34 @@ Rcpp::List silhouette_clusters(arma::mat& data, arma::vec CLUSTER) {
//

// [[Rcpp::export]]
Rcpp::List mini_batch_kmeans(arma::mat& data, int clusters, int batch_size, int max_iters, int num_init = 1, double init_fraction = 1.0, std::string initializer = "kmeans++",

int early_stop_iter = 10, bool verbose = false, Rcpp::Nullable<Rcpp::NumericMatrix> CENTROIDS = R_NilValue, double tol = 1e-4, double tol_optimal_init = 0.5, int seed = 1) {

Rcpp::List mini_batch_kmeans(arma::mat& data,
int clusters,
int batch_size,
int max_iters,
int num_init = 1,
double init_fraction = 1.0,
std::string initializer = "kmeans++",
int early_stop_iter = 10,
bool verbose = false,
Rcpp::Nullable<Rcpp::NumericMatrix> CENTROIDS = R_NilValue,
double tol = 1e-4,
double tol_optimal_init = 0.5,
int seed = 1) {
ClustHeader CRH;

return CRH.mini_batch_kmeans(data, clusters, batch_size, max_iters, num_init, init_fraction, initializer, early_stop_iter, verbose, CENTROIDS, tol, tol_optimal_init, seed);
return CRH.mini_batch_kmeans(data,
clusters,
batch_size,
max_iters,
num_init,
init_fraction,
initializer,
early_stop_iter,
verbose,
CENTROIDS,
tol,
tol_optimal_init,
seed);
}


Expand Down

0 comments on commit d36fc17

Please sign in to comment.