Ensemble Consensus#
consensus
#
| CLASS | DESCRIPTION |
|---|---|
ConsensusEmbedding |
Consensus embedding by aligning and reducing multiple embeddings. |
Attributes#
Classes#
ConsensusEmbedding(estimators: list[ModelType] | dict[str, ModelType], consensus_method: str = 'procrustes_mean', reference_idx: int | str | None = None, estimator_weights: dict[str, float] | None = None, n_iter: int = 5, fit_manager: FitManager | None = None)
#
Bases: Ensemble
Consensus embedding by aligning and reducing multiple embeddings.
Finds consensus low-dimensional representation by aligning embeddings from multiple methods using Procrustes analysis and reduction with various strategies (mean, median, weighted).
| PARAMETER | DESCRIPTION |
|---|---|
estimators
|
Estimators to combine. |
consensus_method
|
Method for finding consensus: "procrustes_mean", "procrustes_median", "weighted_procrustes", "reference_alignment".
TYPE:
|
reference_idx
|
Index or name of reference estimator for "reference_alignment".
TYPE:
|
estimator_weights
|
Weights for each estimator in weighted methods. Keys must match estimator names/indices.
TYPE:
|
n_iter
|
Number of iterations for iterative alignment methods.
TYPE:
|
fit_manager
|
Manager for unified training of both Estimator and Parametric models. Required for using Parametric (PyTorch Lightning) models in consensus ensemble. See FitManager for configuration options.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
estimators |
Fitted estimators with names as keys.
TYPE:
|
consensus_embedding |
The consensus embedding from training data.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
fit |
Fit all estimators and compute consensus embedding. |
predict |
Project new data to consensus embedding space. |
score |
Compute consensus quality score (average alignment score). |
Source code in spectre/ensemble/consensus.py
Attributes#
consensus_embedding: torch.Tensor
property
#
Return consensus embedding.
Functions#
fit(X: torch.Tensor, weights: torch.Tensor | None = None, target: torch.Tensor | None = None) -> ConsensusEmbedding
#
Fit all estimators and compute consensus embedding.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input data of shape (n_samples, in_features).
TYPE:
|
weights
|
Sample weights of shape (n_samples, ).
TYPE:
|
target
|
Target values for supervised methods.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
self
|
Fitted estimator.
TYPE:
|
Source code in spectre/ensemble/consensus.py
predict(X: torch.Tensor) -> torch.Tensor
#
Project new data to consensus embedding space.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input data of shape (n_samples, in_features).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
X_consensus
|
Consensus embedding of shape (n_samples, out_features).
TYPE:
|
Source code in spectre/ensemble/consensus.py
score(X: torch.Tensor, weights: torch.Tensor | None = None, target: torch.Tensor | None = None) -> float
#
Compute consensus quality score (average alignment score).
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input data of shape (n_samples, in_features).
TYPE:
|
weights
|
Sample weights of shape (n_samples, ).
TYPE:
|
target
|
Target values for supervised methods.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
score
|
Average reconstruction score across estimators.
TYPE:
|