Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Plan & Roadmap

The roadmap follows the scikit-learn mapping faithfully, respecting dependencies between crates. Development methodology is as important as the destination. The wave decomposition below comes from the wave-plan-foundation planning change (OpenSpec) — every downstream change references it as the shared reference.

📋
OpenSpec-first

Every change starts with a specification (proposal, deltas, design, tasks) on a dedicated -openspec branch, reviewed before any code.

🔴
Mandatory TDD

Test first, confirmed failure, minimal implementation, refactoring — with companion *_tests.rs modules and mock data in ndarray/sprs.

🌳
Worktree workflow

No direct commits to main. Every change lives in a git worktree with small, focused PRs.

🔍
Independent review

An independent agent validates that the spec was effectively met before every PR.

Iterative evolution per algorithm

No stage may be skipped — each algorithm walks the full path:

1 · Naive implementation
1st
2 · Unit tests (TDD)
2nd
3 · Performance (SIMD/rayon/layout)
3rd
4 · Streaming / out-of-core
4th

Acceptance checklist (every implementation)

  • Runs correctly with lots of data and with little data
  • Correct under concurrency (automatic + applicable explicit modes)
  • Exports model (minimum Safetensors) and produces metrics
  • Companion _tests.rs modules covering everything above
  • Complete names, no abbreviations (single exception: sk/SK)
  • Public items with mandatory prefix; methods unprefixed
  • No file over 200 lines without folder-module organization
  • Python binding in an associated change; GPU backends in separate changes

Phases

Phase 0 — FoundationsComplete

Workspace bootstrap + CI · sciencekit_common traits + central errors · sciencekit_math kernel (pure-Rust faer default) · automatic execution decision + builders + tracing/OTel + allocators.

W0.1–W0.4 landed: bootstrap-workspace, common-core-foundation, math-kernel-foundation, execution-decision-and-observability4/4
Phase 1 — PreprocessingIn progress

SKStandardScaler (dense · incremental partial_fit · out-of-core streaming) · SKMinMaxScaler, SKRobustScaler (tdigest online quantile sketch) · SKOneHotEncoder, SKPolynomialFeatures; imputation strategies (SKSimpleImputer). SKKNNImputer moved to Wave 3, built directly on the trees — no brute-force placeholder.

W1.1 landed: standard-scaler (dense, incremental and out-of-core)1/4
Phase 2 — Linear modelsPlanned

Linear/Ridge/Lasso/ElasticNet/Logistic regressions; SGD classifier/regressor with streaming (SKLazySource).

Phase 3 — Neighbors & SVMIn progress

k-NN classifier/regressor, KD-tree, Ball-tree; SKSVC, SKSVR, LinearSVC.

memmap2-backed indexes and SVM kernel caches, model persistence and model export are deferred to Phase 7 (interop).

Phase 4 — Trees & ensemblesPlanned

Decision trees; Random Forest, Bagging, Gradient Boosting aggregated in parallel with rayon.

Tree persistence and model export are Phase 7 deliverables.

Phase 5 — UnsupervisedIn progress

KMeans, MiniBatchKMeans (streaming), DBSCAN; PCA, TruncatedSVD; anomaly detection.

Phase 6 — Selection, pipelines, metricsPlanned

KFold, train/test split, GridSearchCV; type-safe SKPipeline with DAGs; full metrics suite.

Phase 7 — Interop & productionPlanned

Safetensors sharding/padding/compression, ONNX export/import, Polars/DataFusion sources; umbrella crate; complete PyO3 bindings.

Wave plan and foundational decisions

The wave-plan-foundation planning change decomposes PRD phases 0–7 into waves W0–W7 — roughly 60 downstream changes — so dependencies are respected naturally and no throwaway/placeholder implementations are needed. It also locks six foundational technical decisions that every downstream change references:

⚛
1 · Pure-Rust BLAS/LAPACK

faer 0.24.4 is the default (SKFaerBackend); matrixmultiply is the GEMM fallback; ndarray-linalg+blas-src stays an opt-in blas-backend. oxiblas was disqualified: it does not compile on MSRV 1.85.

🎮
2 · GPU arrival order

OpenCL 3.0 first, ICD-agnostic via opencl3 + the OpenCL loader (vendor-transparent); Metal after; CUDA/ROCm only on request. Heavy algebra stays on CPU.

📊
3 · Online quantile sketch

tdigest 1.0.0 powers SKRobustScaler::partial_fit — a capability scikit-learn lacks (percentiles require the full column).

🗜
4 · Pure-Rust sparse SVD

faer-sparse + rsvd-faer for SKTruncatedSVD; hand-rolled Lanczos fallback; arpack-sys as opt-in. single-svdlib (gold-standard IRLBA) waits on an MSRV bump.

🧵
5 · Nested rayon

rayon owns all parallelism (work-stealing caps threads); BLAS runs single-threaded inside rayon scopes. No semaphore, no threadpoolctl-style hack.

🩹
6 · KNNImputer placement

SKKNNImputer lives in Wave 3, built directly on SKKDTree/SKBallTree — no brute-force placeholder or searcher-trait hack.

Deferred tracker (ADR #37): the nalgebra role for small fixed-size matrices was deferred at W0.3 — not adopted, since sciencekit_math has no small-matrix hot paths yet. Revisit at W5.4 (PCA), adopting nalgebra 0.35 only if faer’s small-matrix performance proves inadequate for 2×2/3×3 covariance.

Cross-cutting (continuous)

Per completed algorithm: Python binding in an associated change; GPU backend (OpenCL 3.0 ICD-agnostic first → Metal after; CUDA/ROCm only on request) in following separate changes.
Recorded for the future: workflows CLI; ONNX/Safetensors import converted to native types with retraining/LoRA support.