Implementation:Scikit learn Scikit learn AgglomerationTransform
| Knowledge Sources | |
|---|---|
| Domains | Machine Learning, Clustering |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for performing feature agglomeration via the transformer interface, provided by scikit-learn.
Description
The AgglomerationTransform class is a mixin that provides transform and inverse_transform methods for feature agglomeration. It pools features into clusters using a configurable pooling function (defaulting to np.mean) and maps data to and from the reduced feature space defined by cluster labels.
Usage
Use this mixin when building hierarchical clustering estimators that need to reduce feature dimensionality by grouping correlated features into clusters. It is used as a base class by FeatureAgglomeration.
Code Reference
Source Location
- Repository: scikit-learn
- File: sklearn/cluster/_feature_agglomeration.py
Signature
class AgglomerationTransform(TransformerMixin):
def transform(self, X):
def inverse_transform(self, X):
Import
from sklearn.cluster._feature_agglomeration import AgglomerationTransform
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| X | array-like of shape (n_samples, n_features) | Yes | Input data matrix to transform or inverse-transform |
Outputs
| Name | Type | Description |
|---|---|---|
| Y | ndarray of shape (n_samples, n_clusters) | The pooled values for each feature cluster (from transform) |
| X_original | ndarray of shape (n_samples, n_features) | Reconstructed values mapped back to original feature space (from inverse_transform) |
Usage Examples
Basic Usage
from sklearn.cluster import FeatureAgglomeration
from sklearn.datasets import make_classification
X, y = make_classification(n_features=20, random_state=0)
agglo = FeatureAgglomeration(n_clusters=5)
X_reduced = agglo.fit_transform(X)
print(X_reduced.shape) # (100, 5)