Hybrid Grid Sampler

A hybrid constraint-based sampler combining LHS and grid sampling.

Overview

  • Uses Latin Hypercube Sampling (LHS) for continuous features

  • Uses grid-like random sampling for discrete features (integer, binary, categorical)

  • Allows custom constraints

  • Parallel sampling supported

API Reference

class mlsampler.engine.hypergrid.HyperGridSampler(config)

Bases: BaseSampler

Hybrid grid and LHS-based constraint sampler.

This sampler generates samples based on feature metadata inferred from training data. Continuous features are sampled using Latin Hypercube Sampling (LHS), while discrete features (e.g., integer, binary, categorical) are sampled using grid random selection over their respective value spaces.

Parameters:

config (SamplerConfig) – Configuration object containing feature metadata and sampling settings.

Notes

Sampling strategy depends on feature data types:

  • Float features:

    Sampled using Latin Hypercube Sampling (LHS), then scaled to their respective [low, high] ranges.

  • Integer features:

    Sampled uniformly from the inclusive range [low, high].

  • Binary features:

    Sampled uniformly from {0, 1}.

  • Categorical features:

    Sampled uniformly from the provided category list.

  • Constant features:

    Always return the same fixed value.

sample(n_samples: int) ndarray
Parameters:

n_samples (int) – Total number of samples to generate.

Returns:

Array of shape (n_samples, n_features) containing the generated samples. The column order matches the input feature configuration.

Return type:

np.ndarray

Notes

  • Float features are scaled to their respective [low, high] ranges.

  • Integer features are sampled from the inclusive range [low, high].

  • Categorical features are sampled from the provided category list.

  • Constant features return the same value for all samples.