modules.applications.qml.generative_modeling.data.data_handler.continuous_data.ContinuousData
- class ContinuousData
Bases:
DataHandlerGenerativeA data handler for continuous datasets. This class loads a dataset from a specified path and provides methods for data transformation and evaluation.
- __init__()
The continuous data class loads a dataset from the path src/modules/applications/qml/generative_modeling/data
Methods
__init__()The continuous data class loads a dataset from the path src/modules/applications/qml/generative_modeling/data
data_load(gen_mod, config)The chosen dataset is loaded and split into a training set.
evaluate(solution)Calculates KL in original space.
Computes generalization metrics.
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)Given an option string by the user, this returns a submodule.
get_depending_parameters(option, config)If the module has parameters depending on certain options, this method should return the parameters for the given option.
Returns the configurable settings for this application.
Returns requirements of this module.
get_submodule(option)Submodule is instantiated according to the information given in self.sub_options.
kl_divergence(target, q)Function to calculate KL divergence.
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:
TypedDictAttributes of a valid config.
data_set: str
- 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 chosen dataset is loaded 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[float, float]
Calculates KL in original space.
- Parameters:
solution -- a dictionary containing the solution data, including histogram_generated_original and histogram_train_original
- Returns:
Kullback-Leibler (KL) divergence for the generated samples and the time it took to calculate it
- generalization() tuple[dict, float]
Computes generalization metrics.
- Returns:
Evaluation and the time it took to create it
- 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) PIT | MinMax
Given an option string by the user, this returns a submodule.
- Parameters:
option -- String with the chosen submodule
- Returns:
Module of type Core
- 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:
Dictionary of parameter options
return { "data_set": { "values": ["X_2D", "O_2D", "MG_2D", "Stocks_2D"], "description": "Which dataset do you want to use?" }, "train_size": { "values": [0.1, 0.3, 0.5, 0.7, 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
- kl_divergence(target: ndarray, q: ndarray) float
Function to calculate KL divergence.
- Parameters:
target -- Probability mass function of the target distribution
q -- Probability mass function generated by the quantum circuit
- Returns:
Kullback-Leibler divergence
- 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