MockDataLab
Data & MLNature / JMLR-style referenceseed 9

Synthetic moons classification dataset

Two interlocking half-circles form the classes, with Gaussian coordinate noise of standard deviation 0.08 and seed 9. Two hundred points are labeled 0 or 1. A linear classifier should struggle. The crescents are generated, not observed.

Arcs before noise

class 0: (cos θ, sin θ); class 1: (1 − cos θ, 1 − sin θ − 0.5); θ from 0 to π

Static snapshotCSV (seed 9) ↓
Interactive dataset studio loads as it enters view…

What this page generates

The moon geometry is a standard picture of a problem that is easy for a nonlinear boundary and awkward for a straight cut. Class 0 traces (cos θ, sin θ) for θ from 0 to π. Class 1 traces (1 − cos θ, 1 − sin θ − 0.5). The second arc sits under the first and is shifted right. Half the rows, rounded up, go to the first arc. The rest go to the second. With 200 rows the split is 100 and 100.

Noise is added to both coordinates after the arc is computed, using two normal draws per point. At 0.08 the crescents stay readable. At a much larger noise they become a single blob and the lesson disappears. The page does not add a third class and does not rotate the figure. Rotation would be a new formula.

Row order is all of class 0, then all of class 1. A train-test split that takes the first 70 percent of the file will see only one class in training if you forget to shuffle. That failure is useful to demonstrate once, and then you should shuffle. The label column is the class. Do not infer class from the sign of x2.

Generating rule

Arcs before noise

class 0: (cos θ, sin θ); class 1: (1 − cos θ, 1 − sin θ − 0.5); θ from 0 to π

Check values

Worked numbers

Seed 9 wrote 200 labeled rows (class 0: 100, class 1: 100). The file lists class 0 first and class 1 second, so shuffle before you split.

Parameters and defaults

Parameters, defaults, and what they change
ParameterDefaultRangeEffect
coordinate noise0.08≥ 0Jitter on both axes. Zero draws the exact arcs.
samples2002 to 20,000Split between the two arcs, first arc rounded up.
seed9unsigned 32-bitRepeats the coordinate jitter.

Python for this seed

Full script with mulberry32() & box_muller() available via Copy Python above

reproduce_seed_9.pyseed 9
# SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com)
# This file is synthetic and must not be presented as real measurements, clinical data, or results from a physical instrument.
# generator: classification-moons
# seed: 9
# samples: 200

# mulberry32() and box_muller() are included when you copy the full script.


SEED = 9
N = 200
rng = mulberry32(SEED)
x1 = np.empty(N, dtype=np.float64)
x2 = np.empty(N, dtype=np.float64)
label = np.empty(N, dtype=np.int64)
first = (N + 1) // 2
second = N - first
cursor = 0
for outer, count in ((False, first), (True, second)):
    for j in range(count):
        theta = 0.0 if count == 1 else math.pi * j / (count - 1)
        nx = (0.08) * box_muller(rng)
        ny = (0.08) * box_muller(rng)
        if outer:
            x1[cursor] = 1.0 - math.cos(theta) + nx
            x2[cursor] = 1.0 - math.sin(theta) - 0.5 + ny
            label[cursor] = 1
        else:
            x1[cursor] = math.cos(theta) + nx
            x2[cursor] = math.sin(theta) + ny
            label[cursor] = 0
        cursor += 1
columns = ["x1", "x2", "label"]
data = np.column_stack([x1, x2, label.astype(np.float64)])

Exercises

  • EXERCISE 01Show a linear SVM failing and a RBF kernel succeeding on the same file.
  • EXERCISE 02Teach shuffle-before-split using a file that is sorted by class.
  • EXERCISE 03Give a plotting test two colors that form crescents rather than round clusters.

Questions

Does this match sklearn.datasets.make_moons?

The arcs follow the same geometry people expect from make_moons. The noise draws do not match scikit-learn, because the seed algorithm differs. Treat it as a sibling fixture, not a drop-in numerical clone.

Which class is the upper crescent?

Class 0 is the upper arc from (1, 0) through (0, 1) to (−1, 0) before noise. Class 1 is the lower arc.

Why are the first table rows all label 0?

The generator writes one arc and then the other. The preview table shows the start of the file.

Related

SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com). Do not present the download as a real measurement.