qxmt.configs module#
- class qxmt.configs.DatasetConfig(*, openml=None, file=None, generate=None, split, features=None, raw_preprocess_logic=None, transform_logic=None)
Bases:
BaseModel
- Parameters:
openml (OpenMLConfig | None)
file (FileConfig | None)
generate (GenerateDataConfig | None)
split (SplitConfig)
features (list[str] | None)
raw_preprocess_logic (list[dict[str, Any]] | dict[str, Any] | None)
transform_logic (list[dict[str, Any]] | dict[str, Any] | None)
- features: list[str] | None
- file: FileConfig | None
- generate: GenerateDataConfig | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- openml: OpenMLConfig | None
- raw_preprocess_logic: list[dict[str, Any]] | dict[str, Any] | None
- split: SplitConfig
- transform_logic: list[dict[str, Any]] | dict[str, Any] | None
- class qxmt.configs.DeviceConfig(*, platform, device_name, backend_name=None, n_qubits, shots=None, random_seed=None, save_shots_results=False)
Bases:
BaseModel
- Parameters:
platform (str)
device_name (str)
backend_name (str | None)
n_qubits (int)
shots (int | None)
random_seed (int | None)
save_shots_results (bool)
- backend_name: str | None
- check_real_machine_setting()
- Return type:
- check_save_shots()
- Return type:
- classmethod check_shots(value)
- Parameters:
value (int)
- Return type:
int
- device_name: str
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- n_qubits: int
- platform: str
- random_seed: int | None
- save_shots_results: bool
- shots: int | None
- class qxmt.configs.EvaluationConfig(*, default_metrics, custom_metrics=None)
Bases:
BaseModel
- Parameters:
default_metrics (list[str])
custom_metrics (list[dict[str, Any]] | None)
- custom_metrics: list[dict[str, Any]] | None
- default_metrics: list[str]
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class qxmt.configs.ExperimentConfig(*, path='', description='', global_settings, dataset, device, feature_map=None, kernel=None, model, evaluation)
Bases:
BaseModel
- Parameters:
path (Path | str)
description (str)
global_settings (GlobalSettingsConfig)
dataset (DatasetConfig)
device (DeviceConfig)
feature_map (FeatureMapConfig | None)
kernel (KernelConfig | None)
model (ModelConfig)
evaluation (EvaluationConfig)
- __init__(**data)
Initialize the experiment configuration.
- Case 1:
Load the configuration from a file path. This case the data is a dictionary with a single key “path”.
- Case 2:
Load the configuration from a dictionary. This case the data is a dictionary with the configuration data.
- Parameters:
data (Any)
- Return type:
None
- dataset: DatasetConfig
- description: str
- device: DeviceConfig
- evaluation: EvaluationConfig
- feature_map: FeatureMapConfig | None
- global_settings: GlobalSettingsConfig
- kernel: KernelConfig | None
- load_from_path(path)
- Parameters:
path (str)
- Return type:
dict[str, Any]
- model: ModelConfig
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- path: Path | str
- class qxmt.configs.FeatureMapConfig(*, module_name, implement_name, params=None)
Bases:
BaseModel
- Parameters:
module_name (str)
implement_name (str)
params (dict[str, Any] | None)
- implement_name: str
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- module_name: str
- params: dict[str, Any] | None
- class qxmt.configs.FileConfig(*, data_path, label_path, label_name)
Bases:
BaseModel
- Parameters:
data_path (Path | str)
label_path (Path | str | None)
label_name (str | None)
- data_path: Path | str
- label_name: str | None
- label_path: Path | str | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(_FileConfig__context)
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- Parameters:
_FileConfig__context (dict[str, Any])
- Return type:
None
- class qxmt.configs.GenerateDataConfig(*, generate_method, params={})
Bases:
BaseModel
- Parameters:
generate_method (Literal['linear'])
params (dict[str, Any] | None)
- generate_method: Literal['linear']
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- params: dict[str, Any] | None
- class qxmt.configs.GlobalSettingsConfig(*, random_seed, task_type)
Bases:
BaseModel
- Parameters:
random_seed (int)
task_type (Literal['classification', 'regression'])
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- random_seed: int
- task_type: Literal['classification', 'regression']
- class qxmt.configs.KernelConfig(*, module_name, implement_name, params=None)
Bases:
BaseModel
- Parameters:
module_name (str)
implement_name (str)
params (dict[str, Any] | None)
- implement_name: str
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- module_name: str
- params: dict[str, Any] | None
- class qxmt.configs.ModelConfig(*, name, params, feature_map=None, kernel=None)
Bases:
BaseModel
- Parameters:
name (str)
params (dict[str, Any])
feature_map (FeatureMapConfig | None)
kernel (KernelConfig | None)
- feature_map: FeatureMapConfig | None
- kernel: KernelConfig | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str
- params: dict[str, Any]
- class qxmt.configs.OpenMLConfig(*, name=None, id=None, return_format='numpy', save_path=None)
Bases:
BaseModel
- Parameters:
name (str | None)
id (int | None)
return_format (str)
save_path (Path | str | None)
- id: int | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(_OpenMLConfig__context)
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- Parameters:
_OpenMLConfig__context (dict[str, Any])
- Return type:
None
- name: str | None
- return_format: str
- save_path: Path | str | None
- class qxmt.configs.SplitConfig(*, train_ratio, validation_ratio=0.0, test_ratio, shuffle=True)
Bases:
BaseModel
- Parameters:
train_ratio (Annotated[float, Ge(ge=0.0), Le(le=1.0)])
validation_ratio (Annotated[float, Ge(ge=0.0), Le(le=1.0)])
test_ratio (Annotated[float, Ge(ge=0.0), Le(le=1.0)])
shuffle (bool)
- check_ratio()
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- shuffle: bool
- test_ratio: float
- train_ratio: float
- validation_ratio: float