Dataset.sampling

Dataset.sampling(sampler: SamplesGenerator | None = None, n_samples: int = 1000, callbacks_class: SamplingCallback | None = None, flag_sample_distrib: bool = False, strategy: str = 'uniform', engine: str = 'sobol', flag_bound_to_range: bool = False, flag_save: bool = True, **kwargs) None | DataFrame[source]

Only a sampling campaign, to obtain design parameters that will be stored.

Optionally, we can provide an ad-hoc function to perform the sampling on the callbacks, and this is run. It still needs to generate as df as output. This callback is run after the sampling, but it can fully override the values provided by it.

Parameters:
  • sampler – An instance of a Sampler class that defines how to generate samples. If None, a sampler will be created based on the specified strategy and engine.

  • n_samples – The number of samples to generate.

  • callbacks_class – An instance of SamplingCallback that defines any additional processing to be done during sampling. This can be used to implement custom sampling strategies or to modify the generated samples

  • before they are saved. The callback should have a method `run` that takes the generated samples as input and returns a modified DataFrame or dictionary of DataFrames.

  • flag_sample_distrib – If True, the sampling strategy will be set to ‘kde’ to sample according to the distribution of existing design parameters. This overrides the specified strategy.

  • strategy – The sampling strategy to use if a sampler is not provided. Options include ‘uniform’, ‘kde’, and ‘quantile’. This is ignored if a sampler instance is provided or if flag_sample_distrib is True.

  • engine – The sampling engine to use if a sampler is not provided. Options include ‘sobol’, ‘halton’, and ‘random’. This is ignored if a sampler instance is provided.

  • flag_bound_to_range – If True, the generated samples will be bounded to the ranges specified in the design parameters’ domains. This is only applicable for certain sampling strategies and engines.

  • flag_save – If True, the generated samples will be saved to disk and added to the dataset. If False, the generated samples will be returned as a DataFrame without saving.

Returns:

If flag_save is False, returns a DataFrame containing the generated samples. If flag_save is True, returns None after saving the samples to disk and updating the dataset.