Small deterministic two-dimensional datasets for MicrogradEx demos.
These helpers intentionally avoid Python, sklearn, NumPy, Nx, and external ML dependencies. They return plain Elixir data structures suitable for scalar micrograd-style training and Livebook visualization.
Summary
Functions
Builds a deterministic two-class blob dataset.
Builds a deterministic two-moons classification dataset.
Builds a deterministic two-class spiral classification dataset.
Types
Functions
@spec blobs(pos_integer(), Keyword.t()) :: MicrogradEx.Datasets.Dataset.t()
Builds a deterministic two-class blob dataset.
This simple baseline is useful for sanity-checking classification and visualization code before moving to moons or spirals.
Options
:noise- non-negative Gaussian noise scale, default0.1:seed- deterministic random seed tuple, default{1337, 1337, 1337}:shuffle- whether to deterministically shuffle rows, defaulttrue:centers- two{x, y}class centers, default[{-1.0, 0.0}, {1.0, 0.0}]
Example
iex> dataset = MicrogradEx.Datasets.blobs(4, noise: 0.0, shuffle: false)
iex> length(dataset.points)
4
@spec moons(pos_integer(), opts()) :: MicrogradEx.Datasets.Dataset.t()
Builds a deterministic two-moons classification dataset.
This is a pure-Elixir equivalent of the dataset used by the official
micrograd demo. Labels are returned as -1.0 and 1.0, matching the
max-margin classification loss used by the training notebook.
Options
:noise- non-negative Gaussian noise scale, default0.1:seed- deterministic random seed tuple, default{1337, 1337, 1337}:shuffle- whether to deterministically shuffle rows, defaulttrue
Example
iex> dataset = MicrogradEx.Datasets.moons(4, noise: 0.0, shuffle: false)
iex> length(dataset.xs)
4
@spec spiral(pos_integer(), Keyword.t()) :: MicrogradEx.Datasets.Dataset.t()
Builds a deterministic two-class spiral classification dataset.
The spiral dataset is useful for showing non-linear decision boundaries. Two
classes share an increasing radius and are separated by a phase shift of
pi.
Options
:noise- non-negative Gaussian noise scale, default0.1:seed- deterministic random seed tuple, default{1337, 1337, 1337}:shuffle- whether to deterministically shuffle rows, defaulttrue:turns- positive number of turns, default1.5
Example
iex> dataset = MicrogradEx.Datasets.spiral(6, noise: 0.0, shuffle: false)
iex> Enum.uniq(dataset.ys)
[-1.0, 1.0]