Skip to content

mlx-learn 0.1.2

Choose a tag to compare

@tabulai tabulai released this 11 Nov 13:43
· 137 commits to main since this release
fb884ca

Install from PyPI with python -m pip install --upgrade mlx-learn==0.1.2. Apple silicon wheels support Python 3.10–3.13.

Added

  • mlxlearn.decomposition.PCA, also available through patch_sklearn(), with
    dense covariance and randomized GPU solvers, host full and arpack solvers,
    whitening, inverse transforms, and probabilistic scores.
  • Regression coverage for shifted inputs, per-feature covariance cancellation,
    whitening, randomized component orthogonality and overflow, low residual
    variance, batch-independent scores, and mixed-dtype or strided transforms.

Changed

  • PCA routes each solver by its measured crossover: covariance_eigh reaches
    the GPU from 8·10⁶ elements or 512 features, randomized from 8·10⁶ elements,
    while full and arpack use the host. Below those floors, patched estimators
    delegate fits to scikit-learn and direct estimators use the host path. See the
    crossover study.
  • Float64 PCA input uses a parallel narrowing cast with a combined range check
    for GPU work. Transforms select their backend before preparing input, avoiding
    unused float32 casts on host projections. Small float64 batches use the host;
    projection centers first when necessary to preserve precision.
  • High-component, low-rank randomized PCA tries a host randomized solve when the
    GPU Gram iteration fails its numerical checks, using a full float64 SVD only
    when the randomized result also fails validation. This removes the unnecessary
    full-SVD slowdown while retaining the accuracy fallback.

Fixed

  • Large offsets no longer erase float64 variation during narrowing. Covariance
    centering guards check every feature, and shifted whitening agrees between
    fit_transform and transform on both CPU and GPU paths.
  • Randomized PCA preserves component orthogonality and resolvable singular values
    on rapidly decaying spectra, rescales power iterations to prevent overflow,
    and computes small residual variance without catastrophic cancellation.
  • Probabilistic PCA scores remain consistent across batch sizes when fitted
    noise variance is small.
  • Mixed float32-fit/float64-query projections compute the mean offset in float64.
    Tiny query variations, strided arrays, original-input range checks, and NaN/Inf
    validation remain covered by regression tests.

Measured

  • Reran 24 MNIST-family configurations, 18 earlier synthetic cases, and 12 scaling
    cases through one million rows. With float64 input and 32 components,
    million-row fits at 256 and 1,024 features measured 5.24× and 12.36×
    faster than scikit-learn; full-training transforms measured 2.42× and
    1.62× faster. Short-query results varied with the measurement sequence:
    the 1,024-feature float64 query took 13.35 ms versus scikit-learn's 3.27 ms
    immediately after the full-training transform, and 2.10 ms versus 2.76 ms
    in a separate query-only run after fitting. See the
    complete results, limitations, and reproduction commands.