Module Datasets.Half_moons

Half moons synthetic dataset generation

module Config : sig ... end

Configuration for the half moons dataset

module Random = Rand.Random_for_tests
val generate_with_kind : (float, 'a) Stdlib__Bigarray.kind -> ?config:Config.t -> len:int -> unit -> (float, 'a, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t * (float, 'a, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t

Internal helper function to generate half moons with specified precision.

  • parameter kind

    The bigarray kind (float32 or float64)

  • parameter config

    Configuration for noise and randomization

  • parameter len

    Number of samples per moon (total samples = len * 2)

  • returns

    A tuple of (coordinates, labels) where:

    • coordinates is a bigarray of shape len*2; 2 (batch_axis, output_axis)
    • labels is a bigarray of shape len*2; 1 (batch_axis, output_axis)
    • First moon has label 1.0, second moon has label -1.0
val generate : ?config:Config.t -> len:int -> unit -> (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t * (float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t

Generate the half moons dataset with the specified parameters.

  • parameter config

    Configuration for noise and randomization

  • parameter len

    Number of samples per moon (total samples = len * 2)

  • returns

    A tuple of (coordinates, labels) where:

    • coordinates is a bigarray of shape len*2; 2 (batch_axis, output_axis)
    • labels is a bigarray of shape len*2; 1 (batch_axis, output_axis)
    • First moon has label 1.0, second moon has label -1.0
val generate_single_prec : ?config:Config.t -> len:int -> unit -> (float, Stdlib.Bigarray.float32_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t * (float, Stdlib.Bigarray.float32_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Genarray.t

Generate the half moons dataset with single precision floats.

  • parameter config

    Configuration for noise and randomization

  • parameter len

    Number of samples per moon (total samples = len * 2)

  • returns

    A tuple of (coordinates, labels) where:

    • coordinates is a bigarray of shape len*2; 2 (batch_axis, output_axis) with float32 elements
    • labels is a bigarray of shape len*2; 1 (batch_axis, output_axis) with float32 elements
    • First moon has label 1.0, second moon has label -1.0
val generate_arrays : ?noise_range:float -> len:int -> unit -> float array * float array

Generate half moons dataset using the old array-based approach for compatibility. This function is deprecated and provided for backwards compatibility.

  • parameter len

    Number of samples per moon

  • parameter noise_range

    Range of noise to add

  • returns

    A tuple of (coordinates_array, labels_array) as flat arrays