Language
Rust
- First appeared
- 2012
- Paradigm
- Multi-paradigm (imperative, functional, generic)
- Toolchain
- Rust 1.99.1
- Container image
rust:1.99.1-slim-trixie
Rust is a compiled systems language, built for the kind of work usually done
in C and C++, with a compiler that checks memory safety before the program
ever runs. Its data science libraries come as crates from crates.io, fetched
by the Cargo package manager. Here there are no crates: each implementation
is a single file compiled with rustc and nothing else, so everything comes
from the standard library. That library is deliberately small. It has
iterators, sorting, hash maps, and file reading, but nothing statistical, so
every formula is written out.
Quirks
- The standard library has no CSV parser, so implementations here split each line on commas by hand (the data files have no quoted fields).
f64isn’tOrd, because NaN compares unequal to everything, sovalues.sort()won’t compile. Usesort_by(f64::total_cmp)instead.- There are no implicit numeric conversions: dividing an
f64by ausizecount is a compile error, so counts are converted withas f64first.
Concepts in Rust
- Cross-validation
- Decision tree
- Descriptive statistics
- k-means clustering
- k-nearest neighbors
- Linear regression
- Logistic regression
- Naive Bayes
- Principal component analysis
Run the examples locally
You need Docker and Python 3. The harness builds the pinned container and runs every Rust example:
git clone https://github.com/qnixon/dswithx.git
cd dswithx
python3 harness/run_tests.py --language rust