From 3ca3ac94009e551d152b56f459fcedc075dac496 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Tue, 9 Jun 2026 09:26:14 -0400 Subject: [PATCH 1/3] modify makevars fixing makevars build issue on windows --- src/Makevars | 1 + src/Makevars.win | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Makevars b/src/Makevars index e9d9765..52c6d51 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1 +1,2 @@ CXX_STD = CXX17 +PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) diff --git a/src/Makevars.win b/src/Makevars.win index e9d9765..52c6d51 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1 +1,2 @@ CXX_STD = CXX17 +PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) From 4d5c7a2902f6189854926cac17644a777eaf31fd Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Tue, 9 Jun 2026 09:26:30 -0400 Subject: [PATCH 2/3] adding soruce to gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index e43b0f9..56bd50b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ .DS_Store + +# Compiled object and shared library files +src/*.o +src/*.so +src/*.dll From c93889ba717b149097877ec864dfc547d323d338 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Tue, 9 Jun 2026 09:27:15 -0400 Subject: [PATCH 3/3] Update swarmbHIVE.R Error in [.default(tb, cl, cl): subscript out of bounds Fix is build the confusion matrix over the union of actual and predicted labels via shared factor levels --- R/swarmbHIVE.R | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/R/swarmbHIVE.R b/R/swarmbHIVE.R index 4932e83..c5fc69e 100644 --- a/R/swarmbHIVE.R +++ b/R/swarmbHIVE.R @@ -143,20 +143,29 @@ swarmbHIVE <- function(X, if (task == "classification") { predicted_labels <- model$assignments actual_labels <- y - + + # Build the confusion matrix over the union of actual and predicted + # labels so it is always square. Without shared levels, a class that the + # model never predicts is absent from the columns, and indexing tb[cl, cl] + # or sum(tb[, cl]) for that class throws "subscript out of bounds". + lvls <- sort(unique(c(as.character(actual_labels), + as.character(predicted_labels)))) + actual_f <- factor(as.character(actual_labels), levels=lvls) + predicted_f <- factor(as.character(predicted_labels), levels=lvls) + if (metric == "accuracy") { return(mean(predicted_labels == actual_labels)) } else if (metric == "balanced_accuracy") { # Balanced accuracy across classes # For multi-class, we can do macro-average recall - tbl <- table(actual_labels, predicted_labels) + tbl <- table(actual_f, predicted_f) # row = actual, col = predicted recalls <- diag(prop.table(tbl, margin=1)) return(mean(recalls, na.rm=TRUE)) } else if (metric == "f1") { # For multi-class, compute macro-F1 # F1_class_i = 2 * precision_i * recall_i / (precision_i + recall_i) - tb <- table(actual_labels, predicted_labels) + tb <- table(actual_f, predicted_f) # row = actual, col = pred f1s <- c() for (cl in rownames(tb)) { @@ -172,7 +181,7 @@ swarmbHIVE <- function(X, return(mean(f1s, na.rm=TRUE)) } else if (metric == "kappa") { # Cohen's Kappa - tb <- table(actual_labels, predicted_labels) + tb <- table(actual_f, predicted_f) n <- sum(tb) p0 <- sum(diag(tb)) / n # Expected agreement under random chance