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 โ€” PreprocessingPlanned

SKStandardScaler, 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.

Phase 2 โ€” Linear modelsPlanned

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

Phase 3 โ€” Neighbors & SVMPlanned

k-NN classifier/regressor, KD-tree, Ball-tree; SVC, SVR, LinearSVC.

Phase 4 โ€” Trees & ensemblesPlanned

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

Phase 5 โ€” UnsupervisedPlanned

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.