Skip to content

Commit

Permalink
Use Partition if Super Partition results in no dimension reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynqueen98 authored Nov 4, 2024
1 parent cb9c48b commit a22ce75
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions R/super_partition.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ super_partition <- function(full_data,
# if < cluster_size features, call regular partition
if (ncol(full_data) < cluster_size) {
message(paste0("Using `partition()` since there are < ", cluster_size, "features."))
return(partition(full_data, threshold = threshold))
return(partition(full_data, threshold, partitioner, tolerance, niter, x, .sep))
}

# iteration counters
Expand Down Expand Up @@ -183,8 +183,11 @@ super_partition <- function(full_data,
)
}

# if no dimension reduction, stop
if (length(unique(master_cluster$cluster)) == ncol(full_data)) stop("No dimension reduction occured. Try a lower threshold.")
# if no dimension reduction, use partition instead
if (length(unique(master_cluster$cluster)) == ncol(full_data)) {
if (verbose) ("No dimension reduction occured using Super Partition. Using Partition instead.")
return(partition(full_data, threshold, partitioner, tolerance, niter, x, .sep))
}

## first cluster - always use largest cluster
clust_sizes <- as.data.frame(table(master_cluster$cluster))
Expand Down

0 comments on commit a22ce75

Please sign in to comment.