Contents

stratifiedSplit(proportions:on:generator:)

Randomly split a MLDataTable into a number partitions while stratifying on a user-define label column.

Declaration

func stratifiedSplit<RNG>(proportions: [Double], on column: String, generator: inout RNG) throws -> MLDataTable where RNG : RandomNumberGenerator

Parameters

  • proportions:

    An array of values on [0,1] specifying the proprtions in each partition. Automatically normalized to 1.

  • column:

    The column in an MLDataTable being stratified on.

  • generator:

    User-defined RandomNumberGenerator to use in stratification.

Return Value

A new MLDataTable with an additional partition column with the index of the partition for each row.

Discussion

The proportions specified will be applied uniformly to each label being partitioned on.

See Also

Splitting a data table