sklears-core
The foundational crate for sklears, providing core traits, types, and utilities that power the entire machine learning ecosystem. Production-ready with 100% test coverage.
Latest release:
0.1.0-alpha.2(December 22, 2025). See the workspace release notes for highlights and upgrade guidance.
Overview
sklears-core provides the fundamental building blocks for all sklears algorithms:
- Core Traits: Comprehensive ML abstractions with type-safe state management
- Advanced Type System: Compile-time validation, phantom types, const generics
- Performance Infrastructure: SIMD, GPU support, memory pooling, parallel processing
- Error Handling: Rich error types with context propagation and recovery
- Integration: scikit-learn compatibility, format I/O, cross-framework support
Status
- Implementation: 0.1.0-alpha.2 ships with >99% of the planned v0.1 APIs implemented.
- Validation: Covered by the 11,292 passing workspace tests (69 skipped) executed on December 22, 2025.
- Performance: Achieves 3-100x improvements as designed via SIMD, threading, and cache-friendly layouts.
- API Stability: Breaking changes still possible before beta; stabilization roadmap tracked in the root
TODO.md.
Core Trait System
Base Traits
Estimator<State>
The foundational trait for all ML models with compile-time state tracking:
Learning Traits
// Supervised learning
// Incremental/online learning
// Unsupervised learning
Prediction Traits
// Standard predictions
// Probabilistic predictions
// Decision scores
Advanced Features
Async Trait Support
GPU Acceleration
use GpuContext;
Type-Safe State Management
Prevent common ML errors at compile time:
use ;
// Model starts untrained
// Only untrained models can be fitted
// Only trained models can predict
This prevents:
- Calling
predict()on untrained models - Accessing parameters before fitting
- Double-fitting models
- All caught at compile time!
Advanced Type System
Compile-Time Validation
use ;
Phantom Types for Safety
use ;
// Type-safe metric selection
Performance Features
SIMD Optimizations
use SimdOps;
// Automatic SIMD acceleration
let distances = euclidean_distance_matrix;
Memory Efficiency
use ;
// Memory pooling for allocations
let pool = new;
let array = pool.?;
// Cache-friendly operations
let accumulator = new;
Error Handling
Rich error types with context:
use ;
Macro System
Powerful macros for boilerplate reduction:
// Quick dataset creation
let dataset = quick_dataset! ;
// ML-specific bounds
define_ml_float_bounds!;
// Automatic test generation
estimator_test_suite!;
Integration & Compatibility
scikit-learn API Compatibility
use SklearnEstimator;
// Drop-in replacement for sklearn models
let model = from_sklearn?;
Cross-Framework Support
// NumPy arrays
let np_array = array.to_numpy?;
// PyTorch tensors
let tensor = array.to_torch_tensor?;
// Polars DataFrames
let df = from_polars?;
Format I/O
Comprehensive format support:
- CSV, JSON, Parquet
- HDF5, NPY/NPZ
- Arrow, Feather
- ONNX, PMML, MLflow
Builder Pattern
Consistent API across all estimators:
let model = builder
.learning_rate
.max_iter
.early_stopping
.validation_fraction
.n_jobs
.random_state
.build?;
Testing Infrastructure
Property-Based Testing
use properties;
proptest!
Mock Objects
use MockEstimator;
let mock = new
.expect_fit
.returning;
Contributing
We welcome contributions! See CONTRIBUTING.md.
License
Licensed under either of:
- Apache License, Version 2.0
- MIT license
Citation