FeatureAgglomeration inverse transforms need both container and feature-width contracts
A correctly shaped value can still arrive in a container the inverse transform rejects. Separate execution success from output-column validation.
Output format is part of the collaboration contract
Shared analysis requires more than shape: the next step must accept the actual returned container. Promising a pandas table differs from promising that the table can be inverse-transformed. Converting to an array to avoid an error still changes the handoff if row labels or cluster-column alignment are lost. [1, 2, 3]
Even an estimator's own output can be rejected
scikit-learn issue 35052 reports FeatureAgglomeration inverse_transform directly indexing its input and failing for list, pandas and Polars containers. It includes tables produced through the estimator's own set_output configuration and contrasts a working NumPy-array path. This supports checking the actual round trip for each supported container, not a claim that all inverse-transformed values are wrong. [1]
Make a conversion workaround explicit
Provide inverse-transform checks for supported containers, and preserve row labels and cluster-column order when using a conversion workaround. Only after successful execution can the output column contract be checked. Creating an empty table after an exception merely to continue validation confuses a failed operation with a valid empty result. [1, 3]
Cluster width is different from original feature width
Define an illustrative original table with 4 features reduced to 2 clusters. Expected inverse-transform width is the original 4. An output with 4 columns satisfies width; passing only 2 columns instead hands over a cluster representation as if it were the original feature representation. Inverse transformation expands representative values to original positions. Width 4 does not establish exact recovery of each original value. [1, 3]
Execution and content contracts need separate checks
ColumnCountValidator in Truthound Core 3.3.2 compares a prepared table's width with a setting such as exact_count. It cannot resolve a container exception. Confirm inverse-transform execution and label alignment first, then safely extract the result as a table and check width. Assessing meaning or information loss requires separate consideration of cluster representatives and their relationship to original features. [1, 2, 3]
Application conditions
Prepare audit records for input_container, row_id, cluster_position and reconstructed_feature_count alongside the actual inverse-transformed output table. Apply ColumnCountValidator to that output table width, not to the audit record column count. Preserve row and column identities.
Alternatives
Pair an explicit array conversion with a label-handoff table and document the supported container path.
Limitations
Inverse transformation expands cluster representative values; it does not mean every original feature value is recovered exactly.
Evidence
- Event checked
- Subject checked
- Modified
