---
title: 'ICSpyLab: Invariant Coordinate Selection'
url: https://www.emergentmind.com/topics/icspylab
type: topic
---

# ICSpyLab: Invariant Coordinate Selection

ICSpyLab is a Python package for invariant coordinate selection (ICS), a linear dimension-reduction method based on the joint diagonalization of two scatter matrices rather than the diagonalization of a single covariance matrix. In the available arXiv literature, it is presented as the first dedicated Python implementation of ICS, designed to bring a method with established relevance for clustering, anomaly detection, and unsupervised linear feature extraction into a unified, scikit-learn-compatible workflow [2606.24521].

## 1. Definition and scope

ICSpyLab implements invariant coordinate selection as a practical software system. ICS is described as a dimensionality reduction technique that seeks informative directions that are not necessarily those of largest variance. This distinguishes it from principal component analysis (PCA), which relies on variance alone. The package motivation is explicitly software-oriented: prior ICS software existed only in R and was split across several packages, which made the method less accessible to Python users and harder to integrate into modern machine-learning workflows [2606.24521].

The package is positioned simultaneously as a practical tool and a research platform. Its implementation follows a standard estimator interface, exposes extensibility points for scatter estimation and component selection, and is intended for both practitioners and methodological work. The surrounding documentation is said to include detailed explanations and reproducible examples, including the RANDU experiment and plotting scripts [2606.24521].

A recurrent source of confusion is the relationship between ICS and PCA. The package paper is explicit that ICS is not simply a variance-based rotation. PCA diagonalizes one scatter matrix, usually the covariance matrix, and therefore finds directions of maximal variance. ICS jointly diagonalizes two scatter matrices and orders directions by discrepancies between two notions of scatter, often interpreted through generalized kurtosis or other non-Gaussian structure. This is why ICS can reveal clustering structure, outlying subspaces, or other deviations from elliptically symmetric Gaussian-like behavior that PCA may miss [2606.24521].

## 2. Mathematical basis of invariant coordinate selection

The central computational object in ICS is a pair of positive definite scatter matrices, denoted \(S_1\) and \(S_2\). A scatter matrix is described as a positive definite matrix summarizing dispersion of a multivariate random vector, generalizing covariance, and satisfying affine equivariance. ICS seeks a matrix \(B\) such that

$$
B S_1 B^\top = I
\qquad \text{and} \qquad
B S_2 B^\top = D,
$$

where \(I\) is the identity and \(D\) is diagonal [2606.24521].

Equivalently, the rows of \(B\) are generalized eigenvectors solving

$$
S_2 v = \lambda S_1 v,
$$

or, when \(S_1\) is invertible,

$$
S_1^{-1} S_2 v = \lambda v.
$$

The invariant coordinates are then obtained by the linear transformation

$$
z_i = B x_i,
$$

or, in matrix form,

$$
Z = X B^\top.
$$

The diagonal entries \(\lambda_j\) of \(D\) are the generalized eigenvalues, and ordering them from largest to smallest or vice versa yields invariant components associated with extreme generalized kurtosis [2606.24521].

The paper also gives an optimization view consistent with the generalized eigenproblem:

$$
\max_{a^\top S_1 a = 1} a^\top S_2 a,
$$

with subsequent directions constrained to be \(S_1\)-orthogonal. In this form, ICS appears as the analogue of PCA’s variance maximization, but with one scatter normalized by another. When \(S_1\) is covariance and \(S_2\) is a fourth-moment-based scatter such as \( \mathrm{cov4} \), the resulting eigenvalues can be interpreted as generalized kurtosis indices [2606.24521].

The whitening formulation clarifies the geometry of the method. If \(S_1 = U \Lambda U^\top\), define

$$
W = \Lambda^{-1/2} U^\top,
$$

so that

$$
W S_1 W^\top = I.
$$

Then diagonalize the whitened second scatter,

$$
W S_2 W^\top = Q D Q^\top,
$$

and obtain

$$
B = Q^\top W.
$$

This construction satisfies the defining joint-diagonalization identities and explains the package’s `whiten` algorithm [2606.24521].

## 3. Package architecture and software abstractions

The core estimator is an `ICS` class inheriting from scikit-learn’s `BaseEstimator`. The interface therefore follows the usual transformer pattern:

- `fit(X)` estimates the invariant-coordinate transformation.
- `transform(X)` applies the fitted transformation.
- `fit_transform(X)` performs both steps in one call.

Because of this design, ICSpyLab can be inserted into pipelines and used with model-selection or cross-validation tooling in the same way as other preprocessing transformers [2606.24521].

Two abstraction layers organize extensibility. The first is `Scatter`, an abstraction for scatter estimators. Since ICS depends critically on the choice of two scatter matrices, this abstraction allows users to plug in custom scatter estimators in addition to those bundled with the package. The second is `ComponentSelect`, an abstraction for component-selection methods. Since one often wants to retain only a subset of invariant components, this layer supports both built-in criteria and custom selection rules [2606.24521].

This architecture reflects the full ICS workflow rather than only the diagonalization step. A typical usage pattern consists of specifying the two scatters \(S_1\) and \(S_2\), choosing an algorithm for computing invariant components, and optionally applying a component-selection rule before downstream clustering or outlier scoring. The paper explicitly describes the resulting integration pattern as a preprocessing stage of the form

$$
X \xrightarrow{\text{ICS}} Z \xrightarrow{\text{clustering/outlier detector}} \text{predictions}.
$$

A plausible implication is that ICSpyLab is intended not merely as a numerical linear-algebra wrapper, but as a composable preprocessing primitive for modern unsupervised workflows [2606.24521].

## 4. Supported scatters, algorithms, and selection criteria

The package exposes a broad collection of scatter matrices, four algorithms for invariant-component computation, and three built-in component-selection criteria. The implementation emphasis is modularity: scatter-matrix choice determines the statistical notion of structure being contrasted, algorithm choice determines how the joint diagonalization is realized numerically, and component selection determines which invariant coordinates are retained for downstream analysis [2606.24521].

| Family | Name | Description |
|---|---|---|
| Scatter | `cov` | classical covariance |
| Scatter | `covW` | weighted covariance linked to Tukey-style ideas |
| Scatter | `cov4` | fourth-moment scatter |
| Scatter | `covAxis` | principal-axis-type scatter |
| Scatter | `mcd` | minimum covariance determinant robust scatter |
| Scatter | `tcov` | pairwise scatter |
| Scatter | `tcovAxis` | axis-based pairwise scatter |
| Scatter | `tM` | multivariate \(t\)-based scatter |

The supported algorithms are `eigh`, `standard`, `whiten`, and `QR`. The paper characterizes them as follows. `eigh` uses a standard symmetric generalized eigensolver from SciPy. `standard` corresponds to the classical ICS implementation approach from the R `ICS` package. `whiten` computes invariant coordinates through whitening with one scatter matrix followed by diagonalization of the other in whitened space. `QR` implements the numerically motivated method from Archimbaud et al. (2023), intended to improve numerical behavior in joint diagonalization [2606.24521].

| Category | Name | Role |
|---|---|---|
| Algorithm | `eigh` | generalized eigensolver from SciPy |
| Algorithm | `standard` | classical ICS implementation approach |
| Algorithm | `whiten` | whitening plus diagonalization |
| Algorithm | `QR` | numerically motivated joint diagonalization |
| Selection | Median criterion | built-in component selection |
| Selection | Normal criterion | built-in component selection |
| Selection | Unimodality criterion | built-in component selection |

The three component-selection criteria are the Median criterion, the Normal criterion, and the Unimodality criterion. The paper attributes the median and normal criteria to Alfons et al. (2024) and the unimodality criterion to Becquart et al. (2026). Although explicit formulas are not given there, the criteria are described as identifying components deviating from Gaussianity or unimodality, which is useful when selecting invariant coordinates for clustering or outlier detection [2606.24521].

The package discussion also makes a methodological point: scatter-matrix choice affects both robustness and computational cost. Classical covariance is simple and efficient but sensitive to contamination; robust and pairwise scatters such as `mcd`, `tcov`, or `tcovAxis` are described as more resilient and often better suited to clustering and anomaly tasks, though potentially more computationally demanding. This suggests that ICSpyLab is best understood as a framework for controlled trade-offs among statistical robustness, numerical behavior, and workflow integration [2606.24521].

## 5. Workflow, PCA comparison, and illustrative use cases

The package paper gives a minimal example:

```python
from icspylab import ICS
from icspylab.distributions import generate_randu

X = generate_randu()
ics = ICS(S1="cov", S2="tcovAxis", algorithm="standard")
X_ics = ics.fit_transform(X)
```

This example uses the RANDU dataset, described as a classical pathological random-number dataset in which observations lie on parallel hyperplanes. With `S1="cov"` and `S2="tcovAxis"`, the paper reports that ICS reveals the hyperplane structure on the last invariant component, whereas PCA fails to reveal it in the corresponding principal components. The example is intended as a reproducible demonstration that informative structure may reside in low-variance directions and therefore be missed by variance-only methods [2606.24521].

The intended use cases emphasized in the package are clustering, anomaly or outlier detection, and unsupervised linear feature extraction. For clustering, the paper notes that effective scatter pairs often combine a matrix capturing global structure with one capturing within-cluster or local structure. Local-shape, pairwise, and robust scatter choices such as `mcd`, `tcov`, or `tcovAxis` are therefore identified as especially relevant. For anomaly detection, ICS is described as advantageous when a small fraction of outliers lies in a low-dimensional subspace, because those directions can emerge in the extreme invariant components [2606.24521].

The comparison with PCA is central to the package’s significance. PCA solves

$$
\Sigma v = \lambda v,
$$

and therefore orders directions by variance. Its components are only orthogonally invariant. ICS, by contrast, compares two scatter structures and is affine invariant. In practical terms, PCA can miss low-variance but highly informative directions, whereas ICS can place those directions among the first or last invariant components depending on the scatter pair. The paper explicitly states that recent work shows ICS outperforming PCA as a preprocessing step for clustering and anomaly detection. A common misconception is therefore that ICS is simply a robustified PCA; the package literature instead presents it as a distinct affine-invariant framework whose ordering criterion depends on disagreement between two scatter notions rather than on variance alone [2606.24521].

## 6. Implementation, availability, and future directions

ICSpyLab is implemented on top of NumPy, SciPy, scikit-learn, Matplotlib, and Numba. Several implementation details are specified. The `mcd` scatter is implemented as a wrapper around scikit-learn’s MCD estimator. Pairwise scatter matrices `tcov` and `tcovAxis` are accelerated using Numba JIT compilation. The use of standard scientific Python libraries is described as supporting reliability and consistency [2606.24521].

The package also includes utilities for experimentation and reproducibility. The paper mentions generators for multivariate exponential power distributions and mixtures of elliptical distributions, as well as visualization tools. This broadens the package from an estimator implementation into an environment for method testing and demonstration. The documentation is said to contain detailed explanations and reproducible examples, and the software is released under the MIT license at `https://github.com/cbecquart/ICSpyLab` [2606.24521].

The limitations identified in the package discussion are mainly methodological rather than infrastructural. The current implementation offers a substantial but still finite set of scatters, algorithms, and selection criteria. ICS itself also requires careful choice of scatter pair and component-selection strategy. Future work identified in the paper includes support for functional data, new component-selection criteria, and methods tailored to high-dimensional settings. The package also emphasizes fostering community contributions in the Python ecosystem [2606.24521].

Within the available arXiv record, the exact title “ICSpyLab” refers to this invariant-coordinate-selection package rather than to unrelated systems in imaging analysis, industrial reverse engineering, or industrial penetration testing, which appear under distinct names such as “The Imaging Computational Microscope” [1502.07009], “ICSREF” [1812.03478], and “ICSSPulse” [2602.20663]. In that sense, ICSpyLab occupies a specific place in the scientific Python ecosystem: it translates a generalized-eigenproblem-based, affine-invariant dimension-reduction method into a coherent software library for clustering, anomaly detection, and extensible methodological research.

Source: https://www.emergentmind.com/topics/icspylab