modules.applications.qml.generative_modeling.data.data_handler.discrete_data.DiscreteData

class DiscreteData

Bases: DataHandlerGenerative

A data handler for discrete datasets with cardinality constraints. This class creates a dataset with a cardinality constraint and provides methods for generalization metrics computing and evaluation.

__init__()

Constructor method.

Methods

__init__()

Constructor method.

data_load(gen_mod, config)

The cardinality constrained dataset is created and split into a training set.

evaluate(solution)

Evaluates a given solution and calculates the histogram of generated samples and the minimum KL divergence value.

generalization()

Calculate generalization metrics for the generated.

get_available_submodule_options()

Gets the list of available options.

get_available_submodules(option)

If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.

get_default_submodule(option)

Get the default submodule based on the given option.

get_depending_parameters(option, config)

If the module has parameters depending on certain options, this method should return the parameters for the given option.

get_parameter_options()

Returns the configurable settings for this application.

get_requirements()

Returns requirements of this module.

get_submodule(option)

Submodule is instantiated according to the information given in self.sub_options.

postprocess(input_data, config, **kwargs)

In this module, the postprocessing step is transforming the data to the correct target format.

preprocess(input_data, config, **kwargs)

In this module, the preprocessing step is transforming the data to the correct target format.

tb_to_pd(logdir, rep)

Converts TensorBoard event files in the specified log directory into a pandas DataFrame and saves it as a pickle file.

class Config

Bases: TypedDict

Attributes of a valid config.

train_size: int
clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
data_load(gen_mod: dict, config: Config) dict

The cardinality constrained dataset is created and split into a training set.

Parameters:
  • gen_mod -- Dictionary with collected information of the previous modules

  • config -- Config specifying the parameters of the data handler

Returns:

Dictionary including the mapped problem

evaluate(solution: dict) tuple[dict, float]

Evaluates a given solution and calculates the histogram of generated samples and the minimum KL divergence value.

Parameters:

solution -- Dictionary containing the solution data, including generated samples and KL divergence values

Returns:

Tuple containing a dictionary with the histogram of generated samples and the minimum KL divergence value, and the time it took to evaluate the solution

generalization() tuple[dict, float]

Calculate generalization metrics for the generated.

Returns:

Tuple containing a dictionary of generalization metrics and the execution time

get_available_submodule_options() list

Gets the list of available options.

Returns:

List of module options

get_available_submodules(option: list) list

If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.

Parameters:

option -- List of chosen options

Returns:

List of available submodules

get_default_submodule(option: str) CircuitCardinality

Get the default submodule based on the given option.

Parameters:

option -- Submodule option

Returns:

Corresponding submodule

get_depending_parameters(option: str, config: dict) dict

If the module has parameters depending on certain options, this method should return the parameters for the given option.

Parameters:
  • option -- The chosen option

  • config -- Current config dictionary

Returns:

The parameters for the given option

get_parameter_options() dict

Returns the configurable settings for this application.

Returns:

A dictionary of parameter options


return {

"train_size": { "values": [0.1, 0.3, 0.5, 0.7, 0.9, 1.0], "description": "What percentage of the dataset do you want to use for training?" }

}

static get_requirements() list[dict]

Returns requirements of this module.

Returns:

List of dict with requirements of this module

get_submodule(option: str) Core

Submodule is instantiated according to the information given in self.sub_options. If self.sub_options is None, get_default_submodule is called as a fallback.

Parameters:

option -- String with the options

Returns:

Instance of a module

postprocess(input_data: dict, config: dict, **kwargs) tuple[dict, float]

In this module, the postprocessing step is transforming the data to the correct target format.

Parameters:
  • input_data -- Original data

  • config -- Config specifying the parameters of the training

  • kwargs -- Optional additional settings

Returns:

Tuple with an output_dictionary and the time it took

preprocess(input_data: dict, config: dict, **kwargs) tuple[any, float]

In this module, the preprocessing step is transforming the data to the correct target format.

Parameters:
  • input_data -- Collected information of the benchmarking process

  • config -- Config specifying the parameters of the training

  • kwargs -- Optional additional settings

Returns:

Tuple with transformed problem and the time it took to map it

static tb_to_pd(logdir: str, rep: str) None

Converts TensorBoard event files in the specified log directory into a pandas DataFrame and saves it as a pickle file.

Parameters:
  • logdir -- Path to the log directory containing TensorBoard event files

  • rep -- Repetition counter