Expand description
§datarust
Scikit-Learn Preprocessing in Rust. A modular, dependency-free
data-preprocessing library built on a lightweight Matrix type
backed by Vec<Vec<f64>>.
§Modules
scaler— StandardScaler, MinMaxScaler, RobustScaler, MaxAbsScaler, Normalizer, Binarizer, KBinsDiscretizer, QuantileTransformer, PowerTransformerencoder— LabelEncoder, OneHotEncoder, OrdinalEncoder, TargetEncoder, FrequencyEncoderimputer— SimpleImputer (mean / median / most_frequent / constant) and KnnImputerpolynomial— PolynomialFeaturesselection— VarianceThreshold, SelectKBestdecomposition— PCA, TruncatedSVDlinear_model— LinearRegression, Ridge, Lasso, LogisticRegressionmetrics— regression metrics (MSE, MAE, R², …) and classification metrics (accuracy, F1, …)model_selection— train_test_split, KFold, StratifiedKFold, cross_val_scorepipeline— sequential Transformer pipelinescompose— ColumnTransformercluster— KMeans (Lloyd’s algorithm, k-means++ initialization)function_transformer— wrap arbitrary functions as a Transformerstats— column and 1-D statistics, covariance and correlation matricesmatrix—Matrix,StrMatrixandSparseMatrixdata containersserialize— JSON save/load (requires theserdefeature)transformer_kind— type-erasedTransformerKindenum wrappercategorical_kind— type-erasedCategoricalTransformerKindenum wrapper for encoderstarget_kind— type-erasedTargetTransformerKindenum wrapper for supervised encoders
All numeric transformers implement the Transformer trait. Supervised
estimators implement Predictor (fit with features + target, then
predict); regressors additionally implement Regressor and classifiers
implement Classifier / PredictProba where appropriate.
Categorical encoders (OneHot, Ordinal, Frequency) implement the
CategoricalTransformer trait.
The TargetEncoder implements the TargetTransformer trait (requires
target values during fit).
The LabelEncoder implements the LabelTransformer trait (1-D
string ↔ int mapping).
Clustering estimators (KMeans) implement the Clusterer trait (fit on
X only, then predict returning cluster indices).
§Features
serde— enables JSON serialization viaserialize.rayon— enables parallel column/row operations for large datasets.matrixmultiply— enables a tuned pure-Rust GEMM (no system BLAS) forMatrix::matmuland covariance computation, speeding up PCA and TruncatedSVD on large dense inputs.datasets— embeds classic toy datasets (Iris, Breast Cancer, Wine, Diabetes) asconstarrays for examples, tests, and onboarding.
The default build has zero external dependencies.
Re-exports§
pub use categorical_kind::CategoricalTransformerKind;pub use cluster::KMeans;pub use cluster::KMeansInit;pub use compose::ColumnSpec;pub use compose::ColumnTransformer;pub use compose::Output;pub use compose::Remainder;pub use compose::Table;pub use encoder::DropStrategy;pub use encoder::FrequencyEncoder;pub use encoder::HandleUnknown;pub use encoder::LabelEncoder;pub use encoder::OneHotEncoder;pub use encoder::OrdinalCategories;pub use encoder::OrdinalEncoder;pub use encoder::OrdinalHandleUnknown;pub use encoder::TargetEncoder;pub use encoder::UnknownFrequency;pub use encoder::UnknownTarget;pub use error::DatarustError;pub use error::Result;pub use label_space::LabelSpace;pub use linear_model::Lasso;pub use linear_model::LinearRegression;pub use linear_model::LinearSolver;pub use linear_model::LogisticRegression;pub use linear_model::LogisticSolver;pub use linear_model::Ridge;pub use linear_model::RidgeSolver;pub use matrix::Matrix;pub use matrix::SparseMatrix;pub use matrix::StrMatrix;pub use model_selection::cross_val_score;pub use model_selection::train_test_split;pub use model_selection::KFold;pub use model_selection::StratifiedKFold;pub use model_selection::TrainTestSplit;pub use pipeline::Pipeline;pub use pipeline::SupervisedPipeline;pub use target_kind::TargetTransformerKind;pub use traits::default_input_names;pub use traits::CategoricalTransformer;pub use traits::Classifier;pub use traits::Clusterer;pub use traits::Estimator;pub use traits::FeatureNames;pub use traits::LabelTransformer;pub use traits::ParamValue;pub use traits::Params;pub use traits::PredictProba;pub use traits::Predictor;pub use traits::Regressor;pub use traits::TargetTransformer;pub use traits::Transformer;pub use transformer_kind::TransformerKind;
Modules§
- categorical_
kind - Enum wrapper for categorical transformer types, enabling serialization of
ColumnTransformerunder theserdefeature. - cluster
- Unsupervised clustering estimators.
- compose
- Composing multiple transformers.
- datasets
- Classic toy datasets for examples, tests, and onboarding.
- decomposition
- Dimensionality reduction: PCA and Truncated SVD.
- encoder
- Categorical encoders.
- error
- Error types returned by fallible operations.
- function_
transformer - Wrap arbitrary functions as a
Transformer. - imputer
- Missing-value imputation.
- label_
space - Compact mapping between original class labels and dense model indices. Compact vocabulary for non-negative integer-valued class labels.
- linalg
- Shared linear-algebra primitives (Cholesky solver, etc.). Linear-algebra primitives shared by estimators.
- linear_
model - Regression & classification estimators: LinearRegression, Ridge, Lasso, LogisticRegression.
Regression estimators with a
fit/predictAPI. - matrix
- Dense and sparse matrix containers used throughout the crate.
- metrics
- Model-evaluation metrics: regression (MSE, R², …) and classification (accuracy, F1, …).
Model-evaluation metrics mirroring
sklearn.metrics. - model_
selection - Model selection: train_test_split, KFold, cross_val_score.
Model-selection utilities mirroring
sklearn.model_selection. - pipeline
- Sequential transformer pipelines.
- polynomial
- Generate polynomial feature combinations.
- scaler
- Feature scaling and discretization transformers.
- selection
- Feature selection.
- serialize
- Optional JSON serialization for fitted transformers (gated on the
serdefeature). - stats
- Column-wise statistics, covariance and correlation helpers.
- target_
kind - Enum wrapper for target (supervised) categorical transformers, enabling
serialization of
ColumnTransformerunder theserdefeature. - traits
- Core traits shared by the numeric and categorical transformers.
- transformer_
kind - Enum wrapper for all transformer types, enabling serialization of
PipelineandColumnTransformerunder theserdefeature.