pyppur.objectives package¶
Objective functions for projection pursuit.
- class pyppur.objectives.BaseObjective(alpha=1.0, **kwargs)[source]
Bases:
ABCAbstract base class for projection pursuit objective functions.
- class pyppur.objectives.DistanceObjective(alpha=0.1, weight_by_distance=False, use_nonlinearity=True, distance_metric='correlation', **kwargs)[source]
Bases:
BaseObjectiveDistance distortion objective function for projection pursuit.
This objective minimizes the difference between pairwise distances in the original space and the projected space. Can optionally apply ridge function nonlinearity before distance computation.
The distance_metric parameter controls how distance preservation is measured: - ‘mse’: Mean squared error between distance matrices (default, scale-sensitive) - ‘correlation’: Negative Pearson correlation (scale-invariant, recommended) - ‘spearman’: Negative Spearman rank correlation (scale and monotonic-invariant)
- class pyppur.objectives.Objective(*values)[source]
Bases:
StrEnumObjective types for projection pursuit.
- DISTANCE_DISTORTION = 'distance_distortion'
- RECONSTRUCTION = 'reconstruction'
- class pyppur.objectives.ReconstructionObjective(alpha=1.0, tied_weights=True, l2_reg=0.0, **kwargs)[source]
Bases:
BaseObjectiveReconstruction loss objective function for projection pursuit.
This objective minimizes the reconstruction error when projecting and reconstructing data. Supports both tied-weights (encoder=decoder) and free decoder configurations.
- reconstruct(X, a_matrix, b_matrix=None)[source]
Reconstruct data from projections.
- Parameters:
X (ndarray) – Input data.
a_matrix (ndarray) – Encoder projection matrix.
b_matrix (ndarray | None) – Decoder matrix (if None, uses tied weights with a_matrix).
- Returns:
Reconstructed data.
- Return type:
ndarray
Submodules¶
pyppur.objectives.base module¶
Base class for objective functions.
pyppur.objectives.distance module¶
Distance distortion objective for projection pursuit.
pyppur.objectives.reconstruction module¶
Reconstruction loss objective for projection pursuit.