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

sciencekit

New In active development · Apache-2.0

All of scikit-learn. Natively in Rust.

sciencekit reimplements every algorithm and utility of scikit-learn from scratch, with extreme performance, memory safety, zero-copy public APIs and native support for datasets larger than RAM.

39+
algorithms mapped
19
crates in the workspace
8
roadmap phases
100%
pure Rust by default

Why does sciencekit exist?

Python ML libraries carry decades of ecosystem — along with the GIL, insecure pickle, and layers of interpretation between your code and the metal. sciencekit brings the same algorithmic reach as scikit-learn to a compiled, native base — no garbage collector, no ergonomic compromises:

⚡
Extreme performance

Native code, SIMD, data parallelism with rayon, and custom allocators selected automatically for your workload.

🛡
Memory safety

All of Rust's guarantees without a garbage collector. Goodbye pickle: models travel as auditable Safetensors or ONNX.

💾
Native out-of-core

Streaming batches or memory-mapping across every algorithm — datasets larger than RAM stop being a blocker.

🧭
First-class concurrency

You choose the execution mode — or the automatic decision engine does: synchronous, asynchronous, streaming or memmap.

The API you will write

Mandatory builder pattern, zero-copy inputs, and full descriptive names — no max_iter anywhere:

// Illustrative — requires the sciencekit crates (Phase 0+).
let model = SKKMeansClassifierBuilder::new()
    .number_of_clusters(8)
    .maximum_iterations(300)
    .execution_mode(SKExecutionMode::Automatic)
    .build()?;

model.fit(&training_data_view)?;
let predictions = model.predict(&test_data_view)?;

Inputs take ArrayView/CowArray (or sparse views via sprs) — never copies of huge matrices. Pipelines are validated at compile time.

Try it in your browser

The example below mirrors the exact shape of the sciencekit API — mandatory builder, full descriptive names, execution_mode on every builder. Edit the code and hit Run: it executes for real, right on the page.

// The sciencekit API follows the builder pattern everywhere.
// This standalone demo mirrors its shape — the real crates arrive with Phase 0.
// Bounded options are enums, never strings, so `execution_mode` cannot be
// misspelled.
#[derive(Debug, Clone, Copy)]
enum SKExecutionMode {
    Automatic,
    InProcessSynchronous,
    OutOfCoreStreaming,
}

#[derive(Debug)]
struct TrainedKMeansModel {
    number_of_clusters: usize,
    maximum_iterations: usize,
    execution_mode: SKExecutionMode,
}

struct KMeansBuilder {
    number_of_clusters: usize,
    maximum_iterations: usize,
    execution_mode: SKExecutionMode,
}

impl KMeansBuilder {
    fn new() -> Self {
        Self {
            number_of_clusters: 3,
            maximum_iterations: 100,
            execution_mode: SKExecutionMode::Automatic,
        }
    }

    fn number_of_clusters(mut self, value: usize) -> Self {
        self.number_of_clusters = value;
        self
    }

    fn maximum_iterations(mut self, value: usize) -> Self {
        self.maximum_iterations = value;
        self
    }

    fn execution_mode(self, mode: SKExecutionMode) -> Self {
        println!("execution mode requested: {mode:?}");
        self
    }

    fn build(self) -> TrainedKMeansModel {
        TrainedKMeansModel {
            number_of_clusters: self.number_of_clusters,
            maximum_iterations: self.maximum_iterations,
            execution_mode: self.execution_mode,
        }
    }
}

fn main() {
    let model = KMeansBuilder::new()
        .number_of_clusters(8)
        .maximum_iterations(300)
        .execution_mode(SKExecutionMode::Automatic)
        .build();

    println!("model ready: {model:?}");
}
How this works: the Run button compiles and executes the code on the official Rust Playground. Once the real sciencekit crates are published, the same examples will run against the library itself.
Current status: Phase 0 (foundations) is complete — Cargo workspace, core traits (SKEstimator, SKRegressorPredictor/SKClassifierPredictor, SKTransformer), the pure-Rust faer math kernel, and the automatic execution-decision + observability layer have all landed. Next up is Phase 1 (preprocessing). Follow the full plan in Plan & Roadmap.

Who is it for?

  • ML engineers in Rust who need a complete, idiomatic toolkit.
  • Python teams that want high-performance inference/training through PyO3 bindings with maximum zero-copy.
  • Production systems where scikit-learn’s pickle is a security risk and every millisecond counts.

The complete reach of scikit-learn,
with the speed and safety of Rust.

Build it with us

The project is open source (Apache-2.0) and advances algorithm by algorithm — naive implementation, tests, performance, out-of-core. Every kind of help is welcome, from docs to GPU backends.