Utilities for dataset inspection, summary statistics, and stratified splitting.
Summary
Functions
Formats a dataset summary map into a human-readable ASCII report.
Splits a dataset into training and validation (or training, validation, and test) sets.
Computes summary statistics on a binary classification dataset.
Functions
Formats a dataset summary map into a human-readable ASCII report.
Splits a dataset into training and validation (or training, validation, and test) sets.
Supports stratified splitting (stratify: true, the default) to preserve class
proportions across all partitions, as well as deterministic random splitting with :seed.
Options
:validation_split- Fraction for validation partition (0.0 < ratio < 1.0). Defaults to0.1.:test_split- Optional fraction for test partition. When provided, returns{train, val, test}.:stratify- Whether to maintain class balance across splits. Defaults totrue.:seed- Optional integer for reproducible random shuffle ordering.:labels- Expected class labels for stratification. Defaults to["0", "1"].:target_threshold- Boundary for soft target binarization. Defaults to0.5.
Examples
{train, val} = BinClass.Dataset.split(data, validation_split: 0.2, seed: 42)
{train, val, test} = BinClass.Dataset.split(data, validation_split: 0.1, test_split: 0.1, seed: 42)
Computes summary statistics on a binary classification dataset.
Calculates total count, class frequencies and distribution percentages, class balance ratio, character length metrics, and estimated word counts.
Options
:labels- The pair of class names, e.g.["0", "1"]or%{0 => "neg", 1 => "pos"}. Defaults to["0", "1"].:target_threshold- Float boundary for soft labels. Defaults to0.5.
Examples
data = [
%{text: "excellent movie", label: 1},
%{text: "awful experience", label: 0}
]
summary = BinClass.Dataset.summary(data)