Note
This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.
AnalysisResult¶
- class AnalysisResult(name=None, value=None, device_components=None, experiment_id=None, result_id=None, chisq=None, quality='unknown', extra=None, verified=False, tags=None, service=None, source=None)[source]¶
Class representing an analysis result for an experiment.
Analysis results can also be stored using the experiments service.
The field
db_data
is a dataclass (ExperimentDataclass) containing all the data that can be stored with the service and loaded from it, and as such is subject to strict conventions.Other data fields can be added and used freely, but they won’t be saved to the database.
Note that the
result_data
field of the dataclass is by itself a dictionary capable of holding arbitrary values (in a dictionary indexed by a string).The data fields in the
db_data
dataclass are:experiment_id
:str
result_id
:str
result_type
:str
device_components
:List[str]
quality
:str
verified
:bool
tags
:List[str]
backend_name
:str
chisq
:float
result_data
:Dict[str]
Analysis data that does not fit into the other fields should be added to the
result_data
dict, e.g. curve parameters in experiments doing a curve fit.AnalysisResult constructor.
- Parameters:
name (str) – analysis result name.
value (Any) – main analysis result value.
device_components (List[DeviceComponent | str]) – Target device components this analysis is for.
experiment_id (str) – ID of the experiment.
result_id (str | None) – Result ID. If
None
, one is generated.chisq (float | None) – Reduced chi squared of the fit.
quality (str | None) – Quality of the analysis. Refer to the experiment service provider for valid values.
extra (Dict[str, Any] | None) – Dictionary of extra analysis result data
verified (bool) – Whether the result quality has been verified.
tags (List[str] | None) – Tags for this analysis result.
service (IBMExperimentService | None) – Experiment service to be used to store result in database.
source (Dict[str, str] | None) – Class and Qiskit version information when loading from an experiment service.
- Returns:
The AnalysisResult object.
- Return type:
Attributes
- RESULT_QUALITY_TO_TEXT = {ResultQuality.BAD: 'bad', ResultQuality.GOOD: 'good', ResultQuality.UNKNOWN: 'unknown'}¶
- auto_save¶
Return current auto-save option.
- Returns:
Whether changes will be automatically saved.
- chisq¶
Return the reduced χ² of this analysis.
- device_components¶
Return target device components for this analysis result.
- Returns:
Target device components.
- experiment_id¶
Return the ID of the experiment associated with this analysis result.
- Returns:
ID of experiment associated with this analysis result.
- extra¶
Return extra analysis result data.
- Returns:
Additional analysis result data.
- name¶
Return analysis result name.
- Returns:
Analysis result name.
- quality¶
Return the quality of this analysis.
- Returns:
Quality of this analysis.
- result_id¶
Return analysis result ID.
- Returns:
ID for this analysis result.
- service¶
Return the database service.
- Returns:
Service that can be used to store this analysis result in a database.
None
if not available.
- source¶
Return the class name and version.
- tags¶
Return tags associated with this result.
- value¶
Return analysis result value.
- Returns:
Analysis result value.
- verified¶
Return the verified flag.
The
verified
flag is intended to indicate whether the quality value has been verified by a human.- Returns:
Whether the quality has been verified.
- version = 1¶
Methods
- classmethod default_source()[source]¶
The default source dictionary to generate
- Return type:
Dict[str, str]
- static format_result_data(value, extra, chisq, source)[source]¶
Formats the result data from the given arguments
- classmethod load(result_id, service)[source]¶
Load a saved analysis result from a database service.
- Parameters:
result_id (str) – Analysis result ID.
service (IBMExperimentService) – the database service.
- Returns:
The loaded analysis result.
- Return type:
- save(suppress_errors=True)[source]¶
Save this analysis result in the database.
- Parameters:
suppress_errors (bool) – should the method catch exceptions (true) or pass them on, potentially aborting the experiment (false).
- Raises:
ExperimentDataError – If the analysis result contains invalid data.
QiskitError – If the save to the database failed.