BinClass.Dataset (BinClass v0.3.0)

Copy Markdown View Source

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

format_summary(summary)

Formats a dataset summary map into a human-readable ASCII report.

split(data, opts \\ [])

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 to 0.1.
  • :test_split - Optional fraction for test partition. When provided, returns {train, val, test}.
  • :stratify - Whether to maintain class balance across splits. Defaults to true.
  • :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 to 0.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)

summary(data, opts \\ [])

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 to 0.5.

Examples

data = [
  %{text: "excellent movie", label: 1},
  %{text: "awful experience", label: 0}
]

summary = BinClass.Dataset.summary(data)