| Crates.io | robust_scaler |
| lib.rs | robust_scaler |
| version | 0.1.0 |
| created_at | 2025-08-22 15:10:44.723047+00 |
| updated_at | 2025-08-22 15:10:44.723047+00 |
| description | A RobustScaler for Rust, compatible with scikit-learn's RobustScaler |
| homepage | |
| repository | https://github.com/Izek1234/robust_scaler |
| max_upload_size | |
| id | 1806488 |
| size | 14,539 |
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.
RobustScalersklearn)ndarray and serdeLazy or ArcAdd to your Cargo.toml:
robust_scaler = "0.1.0"
Or use locally during development:
robust_scaler = { path = "./robust_scaler" }
use robust_scaler::RobustScaler;
let scaler = RobustScaler::from_json("robust_scaler.json")
.expect("Failed to load scaler");
let scaled = scaler.transform_1d(&[1.0, 2.0, 3.0]);
The JSON should be exported from scikit-learn like this:
import json
from sklearn.preprocessing import RobustScaler
scaler = RobustScaler()
scaler.fit(data)
with open("robust_scaler.json", "w") as f:
json.dump({
"center_": scaler.center_.tolist(),
"scale_": scaler.scale_.tolist(),
"n_features_in_": scaler.n_features_in_
}, f)
use ndarray::arr2;
use robust_scaler::RobustScaler;
let data = arr2(&[[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]);
let mut scaler = RobustScaler::new();
scaler.fit(&data);
let scaled = scaler.transform(&data);