Skip to main content

Crate datarust

Crate datarust 

Source
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, PowerTransformer
  • encoder — LabelEncoder, OneHotEncoder, OrdinalEncoder, TargetEncoder, FrequencyEncoder
  • imputer — SimpleImputer (mean / median / most_frequent / constant) and KnnImputer
  • polynomial — PolynomialFeatures
  • selection — VarianceThreshold, SelectKBest
  • decomposition — PCA, TruncatedSVD
  • linear_model — LinearRegression, Ridge, Lasso, LogisticRegression
  • metrics — regression metrics (MSE, MAE, R², …) and classification metrics (accuracy, F1, …)
  • model_selection — train_test_split, KFold, StratifiedKFold, cross_val_score
  • pipeline — sequential Transformer pipelines
  • compose — ColumnTransformer
  • cluster — KMeans (Lloyd’s algorithm, k-means++ initialization)
  • function_transformer — wrap arbitrary functions as a Transformer
  • stats — column and 1-D statistics, covariance and correlation matrices
  • matrixMatrix, StrMatrix and SparseMatrix data containers
  • serialize — JSON save/load (requires the serde feature)
  • transformer_kind — type-erased TransformerKind enum wrapper
  • categorical_kind — type-erased CategoricalTransformerKind enum wrapper for encoders
  • target_kind — type-erased TargetTransformerKind enum 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 via serialize.
  • rayon — enables parallel column/row operations for large datasets.
  • matrixmultiply — enables a tuned pure-Rust GEMM (no system BLAS) for Matrix::matmul and covariance computation, speeding up PCA and TruncatedSVD on large dense inputs.

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 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 ColumnTransformer under the serde feature.
cluster
Unsupervised clustering estimators.
compose
Composing multiple transformers.
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.
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/predict API.
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 serde feature).
stats
Column-wise statistics, covariance and correlation helpers.
target_kind
Enum wrapper for target (supervised) categorical transformers, enabling serialization of ColumnTransformer under the serde feature.
traits
Core traits shared by the numeric and categorical transformers.
transformer_kind
Enum wrapper for all transformer types, enabling serialization of Pipeline and ColumnTransformer under the serde feature.