Expand description
Built-in dataset implementations for machine learning.
dataset-ml provides ready-to-use loaders for classic ML datasets, built on top
of dataset_core::Dataset. Each module is a worked example that shows how to
wrap Dataset<T, E> for one data source. The steps are the same each time:
- Download from a URL.
- Verify a SHA-256 hash.
- Parse CSV records, or extract raw documents from an archive.
- Expose typed accessors backed by
ndarray.
§Datasets
| Module | Samples | Features | Task Type |
|---|---|---|---|
abalone | 4,177 | 8 | Regression |
adult | 32,561 | 14 | Classification |
bank_marketing | 45,211 | 16 | Classification |
banknote_authentication | 1,372 | 4 | Classification |
iris | 150 | 4 | Classification |
breast_cancer | 569 | 30 | Classification |
boston_housing | 506 | 13 | Regression |
california_housing | 20,640 | 8 | Regression |
car_evaluation | 1,728 | 6 | Classification |
covtype | 581,012 | 54 | Classification |
diabetes | 442 | 10 | Regression |
digits | 1,797 | 64 | Classification |
heart_disease | 303 | 13 | Classification |
ionosphere | 351 | 34 | Classification |
kddcup99 | 494,021 / 4,898,431 | 41 | Classification |
letter_recognition | 20,000 | 16 | Classification (26 classes) |
linnerud | 20 | 3 | Regression (multi-output) |
mushroom | 8,124 | 22 | Classification |
spambase | 4,601 | 57 | Classification |
titanic | 891 | 11 | Classification |
palmer_penguins | 344 | 7 | Classification |
sms_spam | 5,574 | text | Classification |
wine_recognition | 178 | 13 | Classification |
wine_quality::red_wine_quality | 1,599 | 11 | Regression |
wine_quality::white_wine_quality | 4,898 | 11 | Regression |
youtube_spam | 1,956 | text | Classification |
sentiment_sentences | 3,000 | text | Classification |
newsgroups20 | 11,314 / 18,846 | text | Classification |
movie_review_polarity | 2,000 | text | Classification |
§Example
use dataset_ml::iris::Iris;
let iris = Iris::new("./data");
let (features, labels) = iris.data().unwrap();
assert_eq!(features.shape(), &[150, 4]);All loaders are lazy: the first call downloads and parses the file, every subsequent call returns a cached reference. See the individual module docs for features, target, sample count, and source.
§Beyond the loaders
Two modules apply to every dataset here rather than to one of them:
preprocessing: seeded train/test and k-fold splits (plain or class-stratified), feature scaling, one-hot encoding, and label encoding. You can feed the arrays a loader returns straight to a model, without writing that glue code by hand.traits: theMlDatasettrait every loader implements. It lets you write code generically over “some dataset”: cache inspection and invalidation, plus a uniformn_samples().
use dataset_ml::preprocessing::{stratified_split, standardize};
use dataset_ml::traits::MlDataset;
use dataset_ml::Iris;
use ndarray::Axis;
let iris = Iris::new("./data");
let (features, labels) = iris.data().unwrap();
// Split with each species proportionally represented on both sides.
let (train, test) = stratified_split(labels.as_slice().unwrap(), 0.2, 42).unwrap();
let (scaled_train, scaler) = standardize(&features.select(Axis(0), &train)).unwrap();
assert_eq!(scaled_train.nrows(), 120);
assert_eq!(iris.n_samples().unwrap(), 150); // from the `MlDataset` traitRe-exports§
pub use abalone::Abalone;pub use adult::Adult;pub use bank_marketing::BankMarketing;pub use banknote_authentication::BanknoteAuthentication;pub use boston_housing::BostonHousing;pub use breast_cancer::BreastCancer;pub use california_housing::CaliforniaHousing;pub use car_evaluation::CarEvaluation;pub use covtype::Covtype;pub use diabetes::Diabetes;pub use digits::Digits;pub use heart_disease::HeartDisease;pub use ionosphere::Ionosphere;pub use iris::Iris;pub use kddcup99::Kddcup99;pub use letter_recognition::LetterRecognition;pub use linnerud::Linnerud;pub use movie_review_polarity::MovieReviewPolarity;pub use mushroom::Mushroom;pub use newsgroups20::Newsgroups20;pub use palmer_penguins::PalmerPenguins;pub use sentiment_sentences::SentimentSentences;pub use sms_spam::SmsSpam;pub use spambase::Spambase;pub use titanic::Titanic;pub use traits::MlDataset;pub use traits::NumSamples;pub use wine_quality::red_wine_quality::RedWineQuality;pub use wine_quality::white_wine_quality::WhiteWineQuality;pub use wine_recognition::WineRecognition;pub use youtube_spam::YoutubeSpam;
Modules§
- abalone
- Abalone dataset module.
- adult
- Adult / Census Income dataset module.
- bank_
marketing - Bank Marketing dataset module.
- banknote_
authentication - Banknote Authentication dataset module.
- boston_
housing - Boston Housing dataset module.
- breast_
cancer - Breast Cancer Wisconsin (Diagnostic) dataset module.
- california_
housing - California Housing dataset module.
- car_
evaluation - Car Evaluation dataset module.
- covtype
- Forest Cover Type dataset module.
- diabetes
- Diabetes dataset module.
- digits
- Optical Recognition of Handwritten Digits dataset module.
- heart_
disease - Heart Disease (Cleveland) dataset module.
- ionosphere
- Ionosphere dataset module.
- iris
- Iris flower dataset module.
- kddcup99
- KDD Cup 1999 network-intrusion dataset module.
- letter_
recognition - Letter Recognition dataset module.
- linnerud
- Linnerud dataset module.
- movie_
review_ polarity - Movie Review Polarity dataset module.
- mushroom
- Mushroom dataset module.
- newsgroups20
- 20 Newsgroups dataset module.
- palmer_
penguins - Palmer Penguins dataset module.
- preprocessing
- Preprocessing helpers.
- sentiment_
sentences - Sentiment Labelled Sentences dataset module.
- sms_
spam - SMS Spam Collection dataset module.
- spambase
- Spambase dataset module.
- titanic
- Titanic dataset module.
- traits
- The
traits::MlDatasettrait implemented by every loader in this crate. - wine_
quality - Wine Quality dataset module.
- wine_
recognition - Wine Recognition dataset module.
- youtube_
spam - YouTube Spam Collection dataset module.
Constants§
- DOWNLOAD_
RETRIES - How many extra download attempts every loader in this crate makes before it stops retrying.