Generator.run
- Generator.run(y_req: List[int | float | bool | str | List], attributes: List[str], n_samples: int, request_orig_range: bool = True, flag_peratt: bool = False, nbins: int = 1, analyzer: AnalysisCallback | None = None, **kwargs) Dict[str, Dict] [source]
Method to generate sets of design parameters given a set of attributes from outputML, and the values for the generation.
- Parameters:
self (object) – The instance of the class containing this method.
request (Dict[str, Union[int, float, bool, str, List]], optional, default=50) – A dictionary with the attributes and values requested for generation. If provided, the y_req and attributes parameters are ignored.
y_req (List[int, float, bool, str, List[int, float, bool, str]], optional, default=50) – The values requested for each of the attributes specified. Depending on the type of attribute, we can have to provide an specific type. Besides, if we want to generate in an interval, we can alternatively provide a List.
attributes (List[str], optional, default=50) – The list of attribute names used to run the generative process.
n_samples (int, optional, optional, default=50) – The number of samples of design parameters to generate.
request_orig_range (bool, optional, optional, default=False) – If True, the y_req is specified within the original range of the real data.
flag_peratt (bool, optional, optional, default=False) – If True, make independent generation requests for each attribute provided.
nbins (int, optional, optional, default=1) – Using nbins is mostly intended for plotting purposes. It allows to generate many different requests in a binarize interval, and compute the error. Hence, it works differently as a request with a provided interval
analyzer (AnalysisCallback, optional, default=None) – If provided, the generator will use the analyzer to compute the ground truth values. This is only possible when the InputML and OutputML are aligned with the DesignParameters and the PerformanceAttributes. If not, these values won’t be computed.
**kwargs (dict) – Additional keyword arguments specific to the generation method.
- Returns:
dict_out (Dict[str, Dict]) – This dictionary contains all the information gathered from the generation process. Hence, it can be used for many purposes, from plotting, to computing errors, or to extract the set of best generated samples
Notes
The ‘y_req’ list should have the same length as the ‘attributes’ list.
If ‘flag_peratt’ is True, ‘n_samples’ will be divided equally among attributes.
- When nbins = 1, the error for the attribute assigned to an interval is 0 if the value is within the interval
When nbins > 1, which is intended for plotting purposes, the error is not 0, but the difference to requested value, which is sampled in that interval
Example:
>>> data_gen = Generator(datamodule, model, over_sample=1) >>> y_req = [3, 4.5, 'bananas'] >>> attributes = ['Age', 'Income', 'Fruit'] >>> samples_gen_dict = data_gen.generation(y_req, attributes, n_samples=100, request_orig_range=True)