robust_scaler
A Rust implementation of scikit-learn's RobustScaler
, designed for robust feature scaling in machine learning pipelines.
RobustScaler
removes the median and scales data according to the interquartile range (IQR), making it robust to outliers.
This crate is ideal for preprocessing input data in ML services, especially when integrating with models trained in Python and deployed in Rust.
🚀 Features
- ✅ Compatible with scikit-learn's
RobustScaler
- ✅ Load from JSON (exported from
sklearn
) - ✅ 1D and 2D data support
- ✅ No external dependencies beyond
ndarray
andserde
- ✅ Thread-safe usage with
Lazy
orArc
- ✅ Perfect for web APIs (e.g., Actix, Axum)
📦 Installation
Add to your Cargo.toml
:
= "0.1.0"
Or use locally during development:
= { = "./robust_scaler" }
🔧 Usage
Load from JSON (recommended for production)
use RobustScaler;
let scaler = from_json
.expect;
let scaled = scaler.transform_1d;
The JSON should be exported from scikit-learn like this:
=
Fit and transform in Rust (for testing)
use arr2;
use RobustScaler;
let data = arr2;
let mut scaler = new;
scaler.fit;
let scaled = scaler.transform;