Skip to content

Main content

Random Train Validation Test Split Generator

Partition supplied IDs into exact row counts with optional exact stratum quotas and whole-group bounded search; group search returns its first feasible result.

Loading tool…

Description

Partition supplied IDs into exact row counts with optional exact stratum quotas and whole-group bounded search; group search returns its first feasible result.

Sampling selects from a supplied population under rules for replacement, grouping, or eligibility. Draw probabilities, inclusion probabilities, and repeat counts describe different aspects of selection; a reproducible sample is not automatically representative of a real population.

Partition supplied IDs into exact row counts with optional exact stratum quotas and whole-group bounded search; group search returns its first feasible result.

When to use this tool

Use this generator to create reproducible train validation test split cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.

How to use the tool and how it works

  1. Supply rows, sizes, grouping, stratification, stratumQuotas in the field shapes below. Set seed when you need an explicit replay.
  2. Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
  3. Read train, validation, test, strata, groups. Use the conventions below and keep answer-bearing fields separate when presenting an exercise.

Validate exact train/validation/test row totals and optional exact stratum quotas. In row mode shuffle within the relevant pools; in whole-group mode use bounded search to assign complete groups while satisfying row and stratum totals. Return splits with stratum/group summaries.1

Input fieldMeaning and unitsAccepted input
rowsRowsRequired. Array of Object; no unknown keys.; minimum items 0; maximum items 128.
rows[].idLiteral identifier used to match records, independently of their display labels.Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
rows[].groupGroupRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
rows[].stratumStratumRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
sizesSizesRequired. Object; no unknown keys.
sizes.trainTrainRequired. Safe integer; minimum 0.
sizes.validationValidationRequired. Safe integer; minimum 0.
sizes.testTestRequired. Safe integer; minimum 0.
groupingGroupingRequired. Text; one of "row", "group".
stratificationStratificationRequired. Text; one of "none", "exact".
stratumQuotasStratum QuotasRequired. Array of Object; no unknown keys.; minimum items 0; maximum items 128.
stratumQuotas[].stratumStratumRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
stratumQuotas[].trainTrainRequired. Safe integer; minimum 0.
stratumQuotas[].validationValidationRequired. Safe integer; minimum 0.
stratumQuotas[].testTestRequired. Safe integer; minimum 0.
seedOptional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed.Optional. Safe integer.
Output fieldInterpretationReturned shape
trainTrainRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 0; maximum items 128.
validationValidationRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 0; maximum items 128.
testTestRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 0; maximum items 128.
strataStrataRequired. Array of Object; no unknown keys.; minimum items 0; maximum items 128.
strata[].stratumStratumRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
strata[].trainTrainRequired. Safe integer; minimum 0.
strata[].validationValidationRequired. Safe integer; minimum 0.
strata[].testTestRequired. Safe integer; minimum 0.
groupsGroupsRequired. Array of Object; no unknown keys.; minimum items 0; maximum items 128.
groups[].groupGroupRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
groups[].splitsSplitsRequired. Array of Text; one of "train", "validation", "test".; minimum items 0; maximum items 3.
randomnessReplay metadata: source is seed or context; seed is the normalized 32-bit seed or null for a context source.Required. Object; no unknown keys.
randomness.seedOptional numeric replay seed; normalization and precedence are explained below.Required. Safe integer. or Null.
randomness.sourceSourceRequired. Text; one of "context", "seed".

An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.

json
{
  "input": {
    "rows": [
      {
        "id": "a",
        "group": "g1",
        "stratum": "oak"
      },
      {
        "id": "b",
        "group": "g2",
        "stratum": "pine"
      },
      {
        "id": "c",
        "group": "g3",
        "stratum": "oak"
      },
      {
        "id": "d",
        "group": "g4",
        "stratum": "pine"
      }
    ],
    "sizes": {
      "train": 2,
      "validation": 1,
      "test": 1
    },
    "grouping": "row",
    "stratification": "none",
    "stratumQuotas": [],
    "seed": 42
  },
  "output": {
    "train": [
      "c",
      "b"
    ],
    "validation": [
      "d"
    ],
    "test": [
      "a"
    ],
    "strata": [
      {
        "stratum": "oak",
        "train": 1,
        "validation": 0,
        "test": 1
      },
      {
        "stratum": "pine",
        "train": 1,
        "validation": 1,
        "test": 0
      }
    ],
    "groups": [
      {
        "group": "g1",
        "splits": [
          "test"
        ]
      },
      {
        "group": "g2",
        "splits": [
          "train"
        ]
      },
      {
        "group": "g3",
        "splits": [
          "train"
        ]
      },
      {
        "group": "g4",
        "splits": [
          "validation"
        ]
      }
    ],
    "randomness": {
      "seed": 42,
      "source": "seed"
    }
  }
}

Limitations and assumptions

  • Distinct row IDs retain provenance. Whole-group search returns its first feasible result and is not uniform over valid partitions. Exact quotas can be incompatible with group sizes, and this split alone does not prevent every form of data leakage.
  • A replay requires the same complete input and implementation. Randomized construction does not guarantee uniform coverage of every feasible output; finite samples can repeat unless a distinct-selection rule is explicitly stated.
  • The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.

Alternative or Complementary methods

For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.

References

  1. Tool behavior and example: Random Train Validation Test Split Generator — tool.io

Similar or alternative tools