Datasets

Synthetic datasets for demonstrating Shape Generalized Trees.

make_plus

sgtlearn.make_plus(n_samples=1500, *, grid=3, margin=0.05, random_state=None)[source]

Generate the “Plus Sign” dataset.

A grid x grid arrangement of cells where the center column and center row form a plus (+) of one class, and the remaining cells are the other class. The boundary is non-monotone in each feature – the pattern an SGT’s shape function captures with a Left/Right/Left split.

Parameters:
  • n_samples (int, default=1500) – Number of points to return.

  • grid (int, default=3) – Number of cells per axis. The plus is the center row/column, so grid should be odd for a centered cross.

  • margin (float, default=0.05) – Width of the empty gap kept around each cell border, so the classes are visually separated. Must be in [0, 0.5).

  • random_state (int, optional) – Seed for reproducibility.

Returns:

  • X (ndarray of shape (n_samples, 2)) – Feature matrix, with both features in [0, grid).

  • y (ndarray of shape (n_samples,)) – Labels: 1 for the plus sign, 0 for the remaining cells.

Return type:

tuple[ndarray, ndarray]