On this page:
3.1 Seeds and reproducibility
3.2 Metadata
3.3 Generators
make-blobs
make-moons
make-circles
make-classification
make-regression
make-friedman1
make-friedman2
make-friedman3
make-hastie-10-2
make-swiss-roll
make-s-curve
make-gaussian-quantiles
9.3

3 Synthetic Data🔗ℹ

 (require datasets/synthetic) package: datasets-core

Each generator mirrors the scikit-learn 1.8 function of the same name and returns a dataset table. Features are named "x0", "x1", …, and hold flonums. The target is "y"; a regression with several targets has "y0", "y1", …, and the two manifolds have "t". Class labels are exact integers.

Keywords follow scikit-learn’s parameters: underscores become hyphens, boolean parameters gain a ?, and random_state becomes #:seed.

Procedure

  

scikit-learn

  

Differences

make-blobs

  

make_blobs

  

#:n-features defaults to #f; centres in metadata, not return_centers

make-moons

  

make_moons

  

none

make-circles

  

make_circles

  

none

make-classification

  

make_classification

  

feature roles in column descriptions, not return_X_y

make-regression

  

make_regression

  

coefficients in metadata, not coef

make-friedman1

  

make_friedman1

  

none

make-friedman2

  

make_friedman2

  

none

make-friedman3

  

make_friedman3

  

none

make-hastie-10-2

  

make_hastie_10_2

  

labels are exact -1 and 1

make-swiss-roll

  

make_swiss_roll

  

none

make-s-curve

  

make_s_curve

  

none

make-gaussian-quantiles

  

make_gaussian_quantiles

  

#:n-features defaults to #f

Arguments scikit-learn accepts but ignores, such as an #:n-features that disagrees with the given centres, are contract violations here. Numbers must be finite as flonums: an exact argument such as (expt 10 400), whose real->double-flonum is infinite, is a contract violation. A bound on an argument must hold for both the value and its flonum, so an exact #:factor just below 1 that rounds to 1.0, or a positive #:class-sep that underflows to 0.0, is also a violation.

3.1 Seeds and reproducibility🔗ℹ

#:seed takes one of four forms:

current-pseudo-random-generator is never read or advanced. Each generator draws in the order of scikit-learn 1.8’s NumPy calls, including draws whose values are then multiplied by zero. On one platform, the same arguments and seed give equal? tables. Across platforms, labels and uniform-only columns are bit-identical; values passed through log, exp, sin, cos or atan agree to a relative 10-12. The stream is not NumPy’s: a seed does not reproduce scikit-learn’s values.

The source metadata’s arguments hash records every keyword with the seed that reproduces the table, so passing it back replays the table.

Examples:
> (define a (make-moons #:n-samples 4 #:noise 0.1 #:seed 7))
> (equal? a (make-moons #:n-samples 4 #:noise 0.1 #:seed 7))

#t

> (hash-ref (hash-ref (dataset-table-info a) "source") "arguments")

'#hash(("n-samples" . 4) ("noise" . 0.1) ("seed" . 7) ("shuffle?" . #t))

3.2 Metadata🔗ℹ

Columns are the features, then the targets. Features have type real and original name X[:, j]. Class labels have type integer; other targets have type real and original name y, y[:, k] or t. Every column has no levels, no unit and no missing values. Descriptions of make-classification features are scikit-learn’s feature_info roles: informative, redundant, repeated or random; make-regression features are informative when their coefficient is nonzero and random otherwise.

The info hash is deeply immutable and has exactly these keys:

Key

  

Value

name

  

the generator’s name, such as "make-blobs"

rows, column-count, columns

  

as for registry datasets

identifiers

  

'()

suggested-targets

  

every target column, in order

source-url

  

the scikit-learn 1.8 page for the function

source-version

  

"scikit-learn 1.8.0 semantics; stream 1, not NumPy-compatible"

source-sha256, sha256, license, time-series

  

#f

citation

  

the reference scikit-learn cites for the generator

notes

  

one sentence

source

  

the hash below

The source hash has generator (the name), reference (such as "sklearn.datasets.make_blobs"), reference-version ("1.8.0"), stream (1), arguments and derived. arguments maps each keyword name, without #:, to its value as given or defaulted; the seed entry is the integer that reproduces the table, or for a generator or vector its state before the first draw. derived holds centers for make-blobs and coef for make-regression, and is empty otherwise. Generated tables are not registry entries.

3.3 Generators🔗ℹ

procedure

(make-blobs [#:n-samples n-samples    
  #:n-features n-features    
  #:centers centers    
  #:cluster-std cluster-std    
  #:center-box center-box    
  #:shuffle? shuffle?    
  #:seed seed]) → dataset-table?
  n-samples : 
(or/c exact-positive-integer?
      (and/c (non-empty-listof exact-nonnegative-integer?)
             (λ (ns) (positive? (apply + ns)))))
   = 100
  n-features : (or/c #f exact-positive-integer?) = #f
  centers : 
(or/c #f exact-positive-integer?
      (non-empty-listof (non-empty-listof rational?)))
   = #f
  cluster-std : 
(or/c (and/c rational? (>=/c 0))
      (non-empty-listof (and/c rational? (>=/c 0))))
   = 1.0
  center-box : (list/c rational? rational?) = '(-10.0 10.0)
  shuffle? : boolean? = #t
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Isotropic Gaussian clusters with standard deviation cluster-std (one per centre when a list). An integer n-samples is split as evenly as possible, earlier centres taking the remainder; a list gives per-centre counts and needs centers to be #f or one centre per count. An integer or #f centers (3 centres) draws the centres uniformly from center-box, whose lower bound must not exceed its upper; the centres are recorded under derived "centers". Explicit centres must have the same dimension, which n-features, when given, must equal; otherwise there are 2 features.

Examples:
> (define b (make-blobs #:n-samples 6 #:centers 2 #:seed 0))
> (dataset-table-names b)

'("x0" "x1" "y")

> (hash-ref (hash-ref (hash-ref (dataset-table-info b) "source") "derived") "centers")

'((7.143136981356072 3.188431217147434) (-5.88690358318294 -1.862973400274866))

procedure

(make-moons [#:n-samples n-samples    
  #:shuffle? shuffle?    
  #:noise noise    
  #:seed seed]) → dataset-table?
  n-samples : 
(or/c exact-positive-integer?
      (list/c exact-nonnegative-integer? exact-nonnegative-integer?))
   = 100
  shuffle? : boolean? = #t
  noise : (or/c #f (and/c rational? (>=/c 0))) = #f
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Two interleaving half circles. Label 0 gets ⌊n-samples/2⌋ points and label 1 the rest; a pair gives the (outer, inner) counts. Gaussian noise of standard deviation noise is added to both features; #f draws nothing.

Example:
> (dataset-table-column (make-moons #:n-samples 5 #:shuffle? #f) "y")

'#(0 0 1 1 1)

procedure

(make-circles [#:n-samples n-samples    
  #:shuffle? shuffle?    
  #:noise noise    
  #:factor factor    
  #:seed seed]) → dataset-table?
  n-samples : 
(or/c exact-nonnegative-integer?
      (list/c exact-nonnegative-integer? exact-nonnegative-integer?))
   = 100
  shuffle? : boolean? = #t
  noise : (or/c #f (and/c rational? (>=/c 0))) = #f
  factor : (and/c rational? (>=/c 0) (</c 1)) = 0.8
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
A unit circle (label 0) containing a circle of radius factor (label 1). Angles are evenly spaced with the endpoint excluded. Counts and noise are as for make-moons.

procedure

(make-classification 
  [#:n-samples n-samples 
  #:n-features n-features 
  #:n-informative n-informative 
  #:n-redundant n-redundant 
  #:n-repeated n-repeated 
  #:n-classes n-classes 
  #:n-clusters-per-class n-clusters-per-class 
  #:weights weights 
  #:flip-y flip-y 
  #:class-sep class-sep 
  #:hypercube? hypercube? 
  #:shift shift 
  #:scale scale 
  #:shuffle? shuffle? 
  #:seed seed]) 
 → dataset-table?
  n-samples : exact-positive-integer? = 100
  n-features : exact-positive-integer? = 20
  n-informative : exact-positive-integer? = 2
  n-redundant : exact-nonnegative-integer? = 2
  n-repeated : exact-nonnegative-integer? = 0
  n-classes : exact-positive-integer? = 2
  n-clusters-per-class : exact-positive-integer? = 2
  weights : (or/c #f (listof (and/c rational? (real-in 0 1))))
   = #f
  flip-y : (and/c rational? (real-in 0 1)) = 0.01
  class-sep : (and/c rational? (>/c 0)) = 1.0
  hypercube? : boolean? = #t
  shift : (or/c #f rational? (non-empty-listof rational?)) = 0.0
  scale : 
(or/c #f (and/c rational? (>/c 0))
      (non-empty-listof (and/c rational? (>/c 0))))
   = 1.0
  shuffle? : boolean? = #t
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Guyon’s design: Gaussian clusters at vertices of a hypercube of side 2·class-sep in the informative features, then redundant features (random linear combinations of the informative ones), repeated features (copies), random features, label flips (each label is redrawn with probability flip-y), shift, scale, and shuffling. A #f shift or scale is drawn per feature. Informative, redundant and repeated features must fit in n-features, and n-classes·n-clusters-per-class vertices in 2n-informative. weights gives the class proportions, with n-classes entries, or n-classes−1 entries summing to at most 1 with the last class taking the rest; a list shift or scale has one entry per feature. Column descriptions name each feature’s role.

Example:
> (for/list ([c (hash-ref (dataset-table-info (make-classification #:n-features 5 #:seed 0)) "columns")])
    (hash-ref c "description"))

'("informative" "random" "redundant" "redundant" "informative" "class label")

procedure

(make-regression [#:n-samples n-samples 
  #:n-features n-features 
  #:n-informative n-informative 
  #:n-targets n-targets 
  #:bias bias 
  #:effective-rank effective-rank 
  #:tail-strength tail-strength 
  #:noise noise 
  #:shuffle? shuffle? 
  #:seed seed]) 
 → dataset-table?
  n-samples : exact-positive-integer? = 100
  n-features : exact-positive-integer? = 100
  n-informative : exact-nonnegative-integer? = 10
  n-targets : exact-positive-integer? = 1
  bias : rational? = 0.0
  effective-rank : (or/c #f exact-positive-integer?) = #f
  tail-strength : (and/c rational? (real-in 0 1)) = 0.5
  noise : (and/c rational? (>=/c 0)) = 0.0
  shuffle? : boolean? = #t
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
A linear model: targets are the features times a coefficient matrix plus bias plus Gaussian noise of standard deviation noise. min(n-informative, n-features) features have coefficients uniform in [0, 100), the rest zero; the coefficients are recorded under derived "coef", one list of n-targets per feature in column order. Features are standard normal, or, when effective-rank is given, a matrix whose singular values follow scikit-learn’s make_low_rank_matrix profile with that rank and tail-strength.

Example:
> (hash-ref (hash-ref (hash-ref (dataset-table-info (make-regression #:n-samples 3 #:n-features 3
                                                                     #:n-informative 1 #:seed 0))
                                "source")
                      "derived")
            "coef")

'((0.0) (50.29567011201274) (0.0))

procedure

(make-friedman1 [#:n-samples n-samples    
  #:n-features n-features    
  #:noise noise    
  #:seed seed]) → dataset-table?
  n-samples : exact-positive-integer? = 100
  n-features : (integer-in 5 #f) = 10
  noise : (and/c rational? (>=/c 0)) = 0.0
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Features uniform on [0, 1); y = 10 sin(π x0 x1) + 20 (x2 − 0.5)2 + 10 x3 + 5 x4 + noise·N(0, 1). Features beyond x4 are unused.

procedure

(make-friedman2 [#:n-samples n-samples    
  #:noise noise    
  #:seed seed]) → dataset-table?
  n-samples : exact-positive-integer? = 100
  noise : (and/c rational? (>=/c 0)) = 0.0
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
x0 uniform on [0, 100), x1 on [40π, 560π), x2 on [0, 1), x3 on [1, 11); y = (x02 + (x1 x2 − 1/(x1 x3))2)1/2 + noise·N(0, 1).

procedure

(make-friedman3 [#:n-samples n-samples    
  #:noise noise    
  #:seed seed]) → dataset-table?
  n-samples : exact-positive-integer? = 100
  noise : (and/c rational? (>=/c 0)) = 0.0
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Inputs as for make-friedman2; y = atan((x1 x2 − 1/(x1 x3))/x0) + noise·N(0, 1).

procedure

(make-hastie-10-2 [#:n-samples n-samples    
  #:seed seed]) → dataset-table?
  n-samples : exact-positive-integer? = 12000
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Ten standard normal features; y is 1 when the sum of their squares exceeds 9.34 and -1 otherwise.

procedure

(make-swiss-roll [#:n-samples n-samples    
  #:noise noise    
  #:hole? hole?    
  #:seed seed]) → dataset-table?
  n-samples : exact-positive-integer? = 100
  noise : (and/c rational? (>=/c 0)) = 0.0
  hole? : boolean? = #f
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
t uniform on [1.5π, 4.5π), x0 = t cos t, x1 uniform on [0, 21), x2 = t sin t, each feature plus noise·N(0, 1). With hole?, (t, x1) is drawn from the eight outer cells of a 3×3 grid on [1.5π, 4.5π) × [0, 21), leaving the centre cell empty.

procedure

(make-s-curve [#:n-samples n-samples    
  #:noise noise    
  #:seed seed]) → dataset-table?
  n-samples : exact-positive-integer? = 100
  noise : (and/c rational? (>=/c 0)) = 0.0
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
t uniform on [−1.5π, 1.5π), x0 = sin t, x1 uniform on [0, 2), x2 = sgn(t)(cos t − 1), each feature plus noise·N(0, 1).

procedure

(make-gaussian-quantiles [#:mean mean 
  #:cov cov 
  #:n-samples n-samples 
  #:n-features n-features 
  #:n-classes n-classes 
  #:shuffle? shuffle? 
  #:seed seed]) 
 → dataset-table?
  mean : (or/c #f (non-empty-listof rational?)) = #f
  cov : (and/c rational? (>=/c 0)) = 1.0
  n-samples : exact-positive-integer? = 100
  n-features : (or/c #f exact-positive-integer?) = #f
  n-classes : exact-positive-integer? = 3
  shuffle? : boolean? = #t
  seed : 
(or/c #f (integer-in 0 (sub1 (expt 2 31)))
      pseudo-random-generator? pseudo-random-generator-vector?)
   = #f
Gaussian points with mean mean (zeros when #f) and covariance cov times the identity, sorted by squared distance from the mean and cut into n-classes nested shells of ⌊n-samples/n-classes⌋ points, the last class taking the remainder. n-features, when given, must equal the length of mean; otherwise there are 2 features. n-samples must be at least n-classes.

Example:
> (dataset-table-column (make-gaussian-quantiles #:n-samples 7 #:n-classes 3 #:shuffle? #f #:seed 0) "y")

'#(0 0 1 1 2 2 2)