Back to Burn

Custom CSV Dataset

examples/custom-csv-dataset/README.md

0.20.11.2 KB
Original Source

Custom CSV Dataset

This example demonstrates two ways to load a CSV dataset and implement the Dataset trait. For this example, we use the diabetes dataset (original source), which contains 442 patient records.

InMemDataset

The custom-csv-dataset example uses InMemDataset::from_csv(path) to read the csv dataset file into a vector (in-memory) of DiabetesPatient records (struct) with the help of serde.

Example Usage

sh
cargo run --example custom-csv-dataset

DataframeDataset (Polars)

The dataframe-dataset example demonstrates using DataframeDataset with Polars as the backend. This approach is well-suited for efficient data manipulation and analysis of larger datasets.

The same diabetes dataset is loaded into a Polars DataFrame, which is then wrapped by DataframeDataset to implement the Dataset trait.

Example Usage

sh
cargo run --example dataframe-dataset --features dataframe