pyppur.objectives package

class pyppur.objectives.BaseObjective(alpha: float = 1.0, **kwargs: Any)[source]

Bases: ABC

Abstract base class for projection pursuit objective functions.

static g(z: ndarray, alpha: float = 1.0) ndarray[source]

Apply the ridge function (non-linearity) to projected data.

Parameters:
  • z – Input data, shape (n_samples, n_components).

  • alpha – Steepness parameter for the ridge function.

Returns:

Transformed data with the same shape as z.

static grad_g(z: ndarray, alpha: float = 1.0) ndarray[source]

Compute the gradient of the ridge function.

Parameters:
  • z – Input data, shape (n_samples, n_components).

  • alpha – Steepness parameter for the ridge function.

Returns:

Gradient values with the same shape as z.

class pyppur.objectives.DistanceObjective(alpha: float = 1.0, weight_by_distance: bool = False, use_nonlinearity: bool = True, **kwargs: Any)[source]

Bases: BaseObjective

Distance 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.

class pyppur.objectives.Objective(*values)[source]

Bases: str, Enum

Objective types for projection pursuit.

DISTANCE_DISTORTION = 'distance_distortion'
RECONSTRUCTION = 'reconstruction'
class pyppur.objectives.ReconstructionObjective(alpha: float = 1.0, tied_weights: bool = True, l2_reg: float = 0.0, **kwargs: Any)[source]

Bases: BaseObjective

Reconstruction 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: ndarray, a_matrix: ndarray, b_matrix: ndarray | None = None) ndarray[source]

Reconstruct data from projections.

Parameters:
  • X – Input data.

  • a_matrix – Encoder projection matrix.

  • b_matrix – Decoder matrix (if None, uses tied weights with a_matrix).

Returns:

Reconstructed data.

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.