Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Machine learning

Solow ships a full machine-learning surface across a set of focused crates. Every estimator has the standard fit / transform / predict shape, every stochastic estimator is deterministic under a caller seed via the portable MMIX-LCG PRNG, and every crate lives under #![forbid(unsafe_code)].

The umbrella solow::prelude re-exports every estimator, so a canonical use solow::prelude::*; gives you the full toolbox.

Where to go next

I need toRead the chapter
Scale, encode, or discretize featuresPreprocessing
Cluster unlabeled dataClustering
Compute nearest-neighbor predictions or densitiesNearest neighbors
Fit a decision treeDecision trees
Combine many trees or classifiersEnsemble methods
Train an SVM classifier or regressorSupport vector machines
Train a multi-layer perceptronNeural networks
Classify with naive-Bayes assumptionsNaive Bayes
Use Fisher LDA or QDADiscriminant analysis
Pick a subset of featuresFeature selection
Chain transformers and tune hyperparametersPipelines & hyperparameter search
Calibrate a classifier's probabilitiesProbability calibration
Train on partially-labeled dataSemi-supervised learning
Fit one classifier per class or per outputMulti-class & multi-output
Vectorize a corpusText feature extraction
Generate or load a benchmark datasetDatasets and toy loaders
Reduce dimensionality (PCA, NMF, ICA)Matrix decomposition
Learn a non-linear manifold (t-SNE, Isomap)Manifold learning
Approximate a kernel with random featuresKernel approximation

One-shot pipeline

#![allow(unused)]
fn main() {
use solow::prelude::*;

let (x, y) = load_breast_cancer();
let pipe = Pipeline::new()
    .step("scale", Box::new(StandardScaler::new()))
    .step("clf",   Box::new(LogisticRegressionCV::new().max_iter(200)));

let cv = StratifiedKFold::new(5)?.shuffle(true).seed(42);
let scores = cross_val_score(&pipe, &x, &y, &cv, |m, xt, yt| {
    Ok(accuracy_score(yt, m.predict(xt)?, None)?)
})?;

println!("accuracy: {:.4} +/- {:.4}", scores.mean, scores.std);
Ok::<_, solow_core::Error>(())
}

References

  • Arthur, D., & Vassilvitskii, S. (2007). k-means++: The advantages of careful seeding. SODA '07, 1027-1035.
  • Ester, M., Kriegel, H.-P., Sander, J., & Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. KDD-96, 226-231.
  • Breiman, L. (2001). Random forests. Machine Learning 45, 5-32.
  • Friedman, J. H. (2001). Greedy function approximation: A gradient boosting machine. Annals of Statistics 29(5), 1189-1232.
  • Shalev-Shwartz, S., Singer, Y., Srebro, N., Cotter, A. (2007). Pegasos: Primal estimated sub-gradient solver for SVM. ICML.