Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Feature Comparison: datarust vs sklearn

A side-by-side view of what’s implemented. ✓ = supported, — = no equivalent.

Preprocessing

Transformerdatarustsklearn
StandardScaler✓ (ddof=0)✓ (ddof=0)
MinMaxScaler✓ (custom range)✓
RobustScaler✓ (centering + scaling)✓
MaxAbsScaler✓✓
Normalizer (L1/L2/Max)✓✓
Binarizer✓✓
KBinsDiscretizer✓ (Uniform/Quantile/KMeans, Ordinal/OneHotDense)✓
QuantileTransformer✓ (Uniform/Normal output)✓
PowerTransformer✓ (Yeo-Johnson/Box-Cox + MLE lambda)✓

Encoders

Transformerdatarustsklearn
LabelEncoder✓ (handle_unknown: Error/Ignore)✓
OrdinalEncoder✓ (auto + manual)✓
OneHotEncoder✓ (drop, handle_unknown, sparse CSR)✓
TargetEncoder✓ (smoothed mean, UnknownTarget)✓
FrequencyEncoder✓ (count/proportion)—

Imputation & Selection

Componentdatarustsklearn
SimpleImputer✓ (mean/median/most_frequent/constant)✓
KNN Imputer✓ (uniform/distance)✓
PolynomialFeatures✓ (degree, interaction_only, bias)✓
VarianceThreshold✓✓
SelectKBest✓ (F-classif / Chi2 / Mutual Info)✓

Models & Decomposition

Componentdatarustsklearn
LinearRegression✓ (Cholesky & SVD)✓
Ridge✓ (L2, Cholesky & SVD)✓
Lasso✓ (L1, coordinate descent)✓
LogisticRegression✓ (IRLS, Cholesky & SVD)✓
DecisionTreeClassifier✓ (CART, Gini/entropy, bit-exact parity)✓
DecisionTreeRegressor✓ (CART, squared error)✓
RandomForestClassifier✓ (bagging, bit-exact parity)✓
RandomForestRegressor✓ (bagging)✓
PCA✓ (Jacobi + randomized SVD, whiten, inverse)✓
TruncatedSVD✓ (Count/Variance/All)✓

Model Selection & Metrics

Componentdatarustsklearn
train_test_split✓✓
KFold / StratifiedKFold✓✓
cross_val_score✓✓
Regression metrics (MSE, R², …)✓ (5 metrics)✓
Classification metrics (accuracy, F1, ROC-AUC, …)✓ (10 metrics)✓
Clustering metrics (silhouette)✓✓
Hyperparameter introspection (Params trait)✓—

Composition & Infrastructure

Featuredatarustsklearn
Pipeline✓ (TransformerKind, serde)✓
ColumnTransformer✓ (numeric + categorical + target)✓
FunctionTransformer✓ (optional inverse, closure-based)✓
FeatureNames✓ (trait, all transformers)✓
inverse_transform✓ (scalers, PCA, SVD, encoders)✓
Pipeline Ergonomics✓ (get/set/insert/remove step)—
Matrix Slicing✓ (select_columns, select_rows)—
Covariance / Correlation✓ (ddof-configurable)—
JSON Serialization✓ (serde feature)— (joblib/pickle)
Sparse Output✓ (CSR via SparseMatrix)✓
Parallelism✓ (rayon feature)— (joblib)

Where datarust goes beyond sklearn

  • FrequencyEncoder — count/proportion encoding not in sklearn.
  • Pipeline runtime editing — get_step, set_step, insert_step, remove_step for live pipeline surgery.
  • JSON serialization — human-readable, language-agnostic fitted-model persistence (vs sklearn’s binary joblib/pickle).
  • Type-safe categorical/numeric separation — the compiler prevents mixing StrMatrix and Matrix.

Rust ecosystem comparison

datarust is a preprocessing-first classical ML library. Within the Rust ecosystem its direct peers are smartcore and linfa. Deep-learning frameworks (candle, burn, tch-rs) solve a different problem and are out of scope here; rusty-machine has been archived and is omitted.

Design philosophies

The three libraries were built around different priorities, which shows up in every design decision:

  • datarust optimizes for preprocessing depth and zero-dependency deployability. All linear algebra is pure Rust (Jacobi eigensolver, Cholesky, coordinate descent), so the default build has no external C libraries — it links cleanly into WASM, embedded targets, and CLI tools. Since v0.7 it also ships CART decision trees and random forests whose splitter reproduces scikit-learn’s bit-for-bit. The remaining trade-off is algorithm breadth: SVM, DBSCAN, and boosting are not implemented yet.
  • smartcore optimizes for single-crate algorithm breadth. One dependency gives you SVM, RandomForest, DecisionTree, KMeans, DBSCAN, KNN, NaiveBayes, and more, plus model selection and metrics. The trade-off is preprocessing: only StandardScaler and OneHotEncoder are provided, and the crate depends on ndarray plus a BLAS backend.
  • linfa optimizes for modularity. Each algorithm family lives in its own crate (linfa-svm, linfa-trees, linfa-clustering, linfa-ensemble, …) behind a shared linfa-core trait surface, so you only compile what you use. linfa-preprocessing additionally offers scalers and text vectorizers (Count / TF-IDF). The trade-off: categorical encoders, imputers, and feature selectors are sparse or undocumented, and Ridge/Lasso exist only through linfa-elasticnet’s l1_ratio parameter.

Feature matrix

Verified against the July 2026 releases: smartcore 0.5.3, linfa 0.8.1. Legend: ✓ present, ✗ confirmed absent, ? not clearly documented at the time of writing — please open an issue or PR if a cell goes stale.

Preprocessing & Encoders

Componentdatarustsmartcorelinfa
StandardScaler✓✓✓
MinMaxScaler✓✗✓
RobustScaler✓✗?
MaxAbsScaler✓✗✓
Normalizer (L1/L2/Max)✓✗✓
KBinsDiscretizer✓✗?
QuantileTransformer✓✗?
PowerTransformer✓✗?
OneHotEncoder✓✓?
OrdinalEncoder✓✗?
LabelEncoder✓✗?
TargetEncoder✓✗✗
FrequencyEncoder✓✗✗
SimpleImputer✓??
KNN Imputer✓??
PolynomialFeatures✓??
VarianceThreshold✓??
SelectKBest✓??
Text vectorizers (Count/TF-IDF)✗✗✓

Models & Decomposition

Componentdatarustsmartcorelinfa
LinearRegression✓✓✓
Ridge (dedicated)✓✗✗ (via ElasticNet l1_ratio=0)
Lasso (dedicated)✓✗✗ (via ElasticNet l1_ratio=1)
LogisticRegression✓✓✓
PCA✓✓✓
TruncatedSVD✓✗✓
SVM✗✓✓
RandomForest / DecisionTree✓ (bit-exact sklearn parity)✓✓
KMeans✓ (k-means++ init)✓✓
DBSCAN✗✓✓

Infrastructure

Featuredatarustsmartcorelinfa
Pipeline✓??
ColumnTransformer✓?✗
train_test_split✓✓?
KFold / StratifiedKFold✓✓?
cross_val_score✓✓?
Regression + Classification metrics✓ (15 metrics + silhouette)✓✓
JSON model serialization✓ (serde)??
Zero external deps by default✓✗ (ndarray + BLAS)✗ (ndarray + BLAS)
WASM-friendly (no native BLAS)✓??
Distribution modelsingle cratesingle crateper-algorithm crates

When to choose which

Your priorityReach for
Rich preprocessing (scalers, encoders, imputers, selection)datarust
WASM / embedded / single-binary deployment, no BLASdatarust
Bit-exact sklearn-parity trees and forests in pure Rustdatarust
SVM, DBSCAN, or the widest single-crate model zoosmartcore
Modular compile-what-you-use algorithms, or text vectorizerslinfa
Deep learning (transformers, CNNs, autograd)candle / burn / tch-rs

Complementary use

These libraries are not mutually exclusive. Because all three expose plain Vec/matrix in/out interfaces, you can mix them in a single pipeline: use datarust for preprocessing (where its coverage is unique), then hand the transformed features to a smartcore or linfa estimator for an algorithm datarust doesn’t implement yet — SVM and DBSCAN are the current examples.