SPB Git

spb/metrika Public

Stata-class statistics, GPU-accelerated by Apple Silicon. Native Swift — no Electron, no Python runtime, no compromises.

Swift 92.4% HTML 3.3% R 3% Shell 1.3%

History of MetrikaKit/Tests/MetrikaKitTests/ElasticNetTests.swift · clear filter

  1. feat(stats): elastic net and lasso via coordinate descent
    - ZQElasticNet: cyclic coordinate descent with residual updates,
      glmnet-convention objective ((1/2n)RSS + lambda(alpha*l1 +
      (1-alpha)/2*l2)), internal predictor standardization (1/n variance),
      unpenalized intercept, coefficients reported on the original scale;
      lambdaMax helper
    - matched glmnet's gaussian y-standardization quirk deliberately: the L1
      penalty is invariant to it but the effective ridge penalty scales by
      1/sd(y) — without this, alpha<1 fits diverge from glmnet by ~10%
    - engine: 'elasticnet y x…, lambda(#) [alpha(#)]' and 'lasso' (alpha
      fixed at 1); missing lambda() errors with the data's lambda_max as a
      hint; predict works afterwards, margins refuses (no VCE)
    - fixtures: glmnet 5.0 at thresh 1e-15 over deliberately correlated
      regressors; coefficients match at 1e-6 (documented tolerance for
      penalized iterative solvers) and the selection pattern (which
      coefficients are exactly zero) matches exactly
    - ZQCoefficient gains a public initializer
    - 104 tests green (swift test and xcodebuild with GPU suites)
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    simon-pierre boucher committed 6 days ago (Aug 5, 2026) · 1 file changed +122