Skip to contents

Generate sets of selected clusters and features from cluster stability selection.

Usage

getCssSelections(
  css_results,
  weighting = "sparse",
  cutoff = 0,
  min_num_clusts = 1,
  max_num_clusts = NA
)

Arguments

css_results

An object of class "cssr" (the output of the function css).

weighting

Character; determines how to calculate the weights for individual features within the selected clusters. Only those features with nonzero weight within the selected clusters will be returned. Must be one of "sparse", "weighted_avg", or "simple_avg". For "sparse", all the weight is put on the most frequently selected individual cluster member (or divided equally among all the clusters that are tied for the top selection proportion if there is a tie). For "weighted_avg", only the features within a selected cluster that were themselves selected on at least one subsample will have nonzero weight. (Exception: if no member of a selected cluster was selected on any subsample, the weights fall back to a simple average, so all of that cluster's members are returned.) For "simple_avg", each cluster member gets equal weight regardless of the individual feature selection proportions (that is, all cluster members within each selected cluster will be returned.). See Faletto and Bien (2022) for details. Default is "sparse".

cutoff

Numeric; getCssSelections will select and return only of those clusters with selection proportions equal to at least cutoff. Must be between 0 and 1. Default is 0 (in which case either all clusters are selected, or max_num_clusts are selected, if max_num_clusts is specified).

min_num_clusts

Integer or numeric; the minimum number of clusters to use regardless of cutoff. (That is, if the chosen cutoff returns fewer than min_num_clusts clusters, the cutoff will be lowered until at least min_num_clusts clusters are selected.) Default is 1. May be set to 0 to allow a pure cutoff-based (threshold) selection that returns an empty set when no cluster's selection proportion meets the cutoff.

max_num_clusts

Integer or numeric; the maximum number of clusters to use regardless of cutoff. (That is, if the chosen cutoff returns more than max_num_clusts clusters, the cutoff will be raised until at most max_num_clusts clusters are selected.) Default is NA (in which case max_num_clusts is ignored). Because clusters can have tied selection proportions, ties at the threshold can cause more than max_num_clusts (or fewer than min_num_clusts) clusters to be returned; when the two constraints conflict, max_num_clusts takes precedence.

Value

A named list with three items.

selected_clusts

A named list of integer vectors; each vector contains the indices of the features in one of the selected clusters.

selected_feats

A named integer vector; the indices of the features with nonzero weights from all of the selected clusters.

weights

A named list of the same length as selected_clusts. Each list element weights[[j]] is a numeric vector of the weights to use for the jth selected cluster, and it has the same name as the cluster it corresponds to.

References

Faletto, G., & Bien, J. (2022). Cluster Stability Selection. arXiv preprint arXiv:2201.00494. https://arxiv.org/abs/2201.00494.

Author

Gregory Faletto, Jacob Bien

Examples

set.seed(1)
data <- genClusteredData(n = 50, p = 11, k_unclustered = 2,
  cluster_size = 4, n_clusters = 1, snr = 3)
clusters <- list(cluster1 = 1:4)
res <- css(X = data$X, y = data$y, lambda = 0.01, clusters = clusters,
  B = 10)
getCssSelections(res)
#> $selected_clusts
#> $selected_clusts$cluster1
#> [1] 1 2 3 4
#> 
#> $selected_clusts$c2
#> [1] 5
#> 
#> $selected_clusts$c3
#> [1] 6
#> 
#> $selected_clusts$c4
#> [1] 7
#> 
#> $selected_clusts$c5
#> [1] 8
#> 
#> $selected_clusts$c6
#> [1] 9
#> 
#> $selected_clusts$c7
#> [1] 10
#> 
#> $selected_clusts$c8
#> [1] 11
#> 
#> 
#> $selected_feats
#> [1]  3  5  6  7  8  9 10 11
#> 
#> $weights
#> $weights$cluster1
#> [1] 0 0 1 0
#> 
#> $weights$c2
#> [1] 1
#> 
#> $weights$c3
#> [1] 1
#> 
#> $weights$c4
#> [1] 1
#> 
#> $weights$c5
#> [1] 1
#> 
#> $weights$c6
#> [1] 1
#> 
#> $weights$c7
#> [1] 1
#> 
#> $weights$c8
#> [1] 1
#> 
#>