setup_SpectralRBF: Setup SpectralRBFConfig

View source: R/120_ClusteringConfig.R

setup_SpectralRBFR Documentation

Setup SpectralRBFConfig

Description

Setup a SpectralRBFConfig object for spectral clustering with a Gaussian (radial basis function) kernel, via the 'kernlab' package.

Usage

setup_SpectralRBF(
  k = 3L,
  sigma = NULL,
  sigma_sample_fraction = NULL,
  iterations = 200L,
  nystrom = NULL,
  features = NULL
)

Arguments

k

Integer [2, Inf): Number of clusters. Must be no more than the number of cases.

sigma

Optional Numeric (0, Inf): Inverse kernel width. Unset estimates it from the data.

sigma_sample_fraction

Optional Numeric (0, 1]: Fraction of the cases the kernel width is estimated from when sigma is unset. Unset uses three quarters of them.

iterations

Integer [1, Inf): Maximum number of k-means iterations run on the spectral embedding.

nystrom

Optional NystromConfig: Approximate the affinity matrix from a sample of the cases, from setup_Nystrom. NULL decomposes it in full.

features

Optional Character vector: Names of at least 2 distinct feature columns to cluster on. NULL clusters on all numeric features.

Details

Spectral clustering builds a similarity graph over the cases, embeds them in the leading eigenvectors of that graph's normalized Laplacian, and runs k-means there. Groups that are connected but not compact – concentric rings, elongated bands – separate in that embedding while k-means on the raw features cannot find them. This variant measures similarity with a Gaussian kernel whose width is shared by every case; see setup_SpectralLocal for a per-case width and setup_SpectralLaplace for an exponential kernel.

The cost is cubic in the number of cases, since the whole affinity matrix is decomposed. Pass nystrom to approximate the decomposition from a sample instead.

Argument names are rtemis' own. They map to kernlab::specc() as: k -> centers, sigma -> kpar = list(sigma) with kernel = "rbfdot", sigma_sample_fraction -> mod.sample (with kpar = "automatic" when sigma is unset), nystrom -> nystrom.red and nystrom.sample; iterations keeps its name.

Value

SpectralRBFConfig object.

Author(s)

EDG

References

Ng AY, Jordan MI, Weiss Y (2001). On Spectral Clustering: Analysis and an Algorithm. Advances in Neural Information Processing Systems, 14, 849-856.

Examples

spectral_config <- setup_SpectralRBF(k = 3L)
spectral_config
setup_SpectralRBF(k = 3L, nystrom = setup_Nystrom(sample = 100L))

rtemis documentation built on Oct. 20, 2026, 1:06 a.m.