std1.0.0-beta-7 SafeC docs

std :: ml::datasets

Struct std::Dataset

#include <std/ml/datasets.h> source

struct Dataset {
    &FloatTensor x;
    &FloatTensor y;
    unsigned long n;
    unsigned long features;
    unsigned long targets;
    unsigned long classes;
}

Fields

[n, features]

[n, targets]

§unsigned long nsource
§unsigned long featuressource
§unsigned long targetssource
§unsigned long classessource

0 for regression / unlabeled

Methods

§struct DatasetSplit split(float testFraction, &Rng rng) constsource · definition

Shuffles, then puts 'testFraction' of the rows in 'test'.

§void standardize()source · definition

Mean 0, std 1 per feature column, from the set's own statistics.

§void standardize_pair(&Dataset test)source · definition

The same with this set's statistics applied to it and 'test' (no test leakage).

§void drop()source · definition
§void free() consumesource · definition

= drop()

§static struct Dataset moons(unsigned long n, float noise, &Rng rng)source · definition

Two interleaved half circles, 2 classes (scikit-learn's make_moons).

§static struct Dataset circles(unsigned long n, float noise, float factor, &Rng rng)source · definition

A circle inside a larger one, radius ratio 'factor', 2 classes.

§static struct Dataset spirals( unsigned long n, unsigned long classes, float noise, &Rng rng, )source · definition

'classes' interleaved spiral arms.

§static struct Dataset blobs( unsigned long n, unsigned long classes, unsigned long features, float spread, &Rng rng, )source · definition

Isotropic Gaussian clusters in 'features' dimensions, centers in [-5, 5].

§static struct Dataset xor(unsigned long n, float noise, &Rng rng)source · definition

The four XOR quadrants of [-1, 1]^2, 2 classes.

§static struct Dataset sine(unsigned long n, float noise, &Rng rng)source · definition

Regression: x uniform in [-pi, pi], y = sin(x) + noise.

§static struct Dataset gaussian_ring( unsigned long n, unsigned long modes, float radius, float std, &Rng rng, )source · definition

'modes' Gaussians (std 'std') evenly spaced on a circle of 'radius'; the label is the mode.

§static struct Dataset shapes(unsigned long n, unsigned long side, &Rng rng)source · definition

side x side binary images, flattened row-major, pixels 0 or 1. Classes: 0 square outline, 1 plus sign, 2 filled disc, 3 diagonal cross; random size and position. side >= 8.

§static struct Dataset load_mnist( const &char imagesPath, const &char labelsPath, unsigned long limit, )source · definition

MNIST / Fashion-MNIST IDX files (uncompressed): images as [n, 784] scaled to [0, 1], 10 classes. 'limit' 0 reads every image. On any error the result has n == 0.

§static struct Dataset load_csv( const &char path, long labelColumn, int hasHeader, int classification, )source · definition

A numeric CSV: one row per line, comma-separated. 'labelColumn' -1 makes the set unlabeled; otherwise that column becomes y, and with 'classification' the labels are class indices (classes = max + 1). The first line is skipped when 'hasHeader'. n == 0 on error.