Skip to content

Roadmap #1: optimize GaussianNB.fit #210

Closed

Description

@godofecht

Source: benchmarks/OPTIMIZATION_ROADMAP.md rank 1.

  • Estimator: GaussianNB
  • Operation: fit
  • Substrate: python-bound
  • Priority score: 75.3
  • Disposition: rewrite first
  • Observed Flow speedup: 11.03×
  • Hypothesis: remove Python control/validation and specialize the complete operation.

Acceptance: preserve sklearn parity, implement or conclusively evaluate the optimization hypothesis, add/update benchmark evidence, and update the roadmap disposition/evidence before closing.

Implementation evidence

PR #316 replaces per-feature and per-class-feature temporary arrays/rescans with cached class indices plus two contiguous sufficient-statistics passes over the row-major matrix. A dedicated regression test checks priors, means, ddof=0 variances, and predictions.

Scaled benchmark evidence from Actions run 32016935346 versus committed baseline run 32002315336 shows GaussianNB fit latency improvements at every measured size:

  • 100 × 8: 0.032020 ms → 0.013600 ms (2.35× faster; 57.5% lower)
  • 100 × 32: 0.109555 ms → 0.039128 ms (2.80× faster; 64.3% lower)
  • 1,000 × 8: 0.263293 ms → 0.104094 ms (2.53× faster; 60.5% lower)
  • 1,000 × 32: 1.000052 ms → 0.371671 ms (2.69× faster; 62.8% lower)
  • 10,000 × 8: 1.855453 ms → 0.831372 ms (2.23× faster; 55.2% lower)
  • 10,000 × 32: 7.953373 ms → 3.050000 ms (2.61× faster; 61.7% lower)

The scaled self-baseline gate passed. Canonical 19/19 parity and generated architecture/roadmap evidence also passed on the implementation. The unrelated native Python wheel source-path blocker discovered during validation was fixed on main via #201. PR #316 has been rebased cleanly onto that current main and contains only the GaussianNB source/test changes. Keep this issue open until the fresh rebased checks finish and #316 lands.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions