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.
CurveAnalysis¶
- class CurveAnalysis(models=None, name=None)[source]¶
Base class for curve analysis with single curve group.
The fit parameters from the series defined under the analysis class are all shared and the analysis performs a single multi-objective function optimization.
A subclass may override these methods to customize the fit workflow.
_run_data_processing
This method performs data processing and returns the processed dataset. By default, it internally calls the
DataProcessor
instance from the data_processor analysis option and processes the experiment data payload to create Y data with uncertainty. X data and other metadata are generated within this method by inspecting the circuit metadata. The series classification is also performed based upon the matching of circuit metadata andSeriesDef.filter_kwargs
._format_data
This method consumes the processed dataset and outputs the formatted dataset. By default, this method takes the average of y values over the same x values and then sort the entire data by x values.
_generate_fit_guesses
This method creates initial guesses for the fit parameters. See Providing initial guesses for details.
_run_curve_fit
This method performs the fitting with predefined fit models and the formatted dataset. This method internally calls the
_generate_fit_guesses()
method. Note that this is a core functionality of the_run_analysis()
method, that creates fit result objects from the formatted dataset._evaluate_quality
This method evaluates the quality of the fit based on the fit result. This returns “good” when reduced chi-squared is less than 3.0. Usually it returns string “good” or “bad” according to the evaluation.
_create_analysis_results
This method creates analysis results for important fit parameters that might be defined by analysis options
result_parameters
._create_curve_data
This method creates analysis results containing the formatted dataset, i.e. data used for the fitting. Entries are created when the analysis option
return_data_points
isTrue
. If analysis consists of multiple series, an analysis result is created for each series definition._initialize
This method initializes analysis options against input experiment data. Usually this method is called before other methods are called.
Initialize data fields that are privately accessed by methods.
- Parameters:
models (
Optional
[List
[Model
]]) – List of LMFITModel
class to define fitting functions and parameters. If multiple models are provided, the analysis performs multi-objective optimization where the parameters with the same name are shared among provided models. When multiple models are provided, user must specify thedata_subfit_map
value in the analysis options to allocate experimental results to a particular fit model.name (
Optional
[str
]) – Optional. Name of this analysis.
Attributes
A short-cut for curve drawer instance, if set.
Return fit models.
Return name of this analysis.
Return the analysis options for
run()
method.Return parameters of this curve analysis.
A short-cut to the curve plotter instance.
Methods
Return the config dataclass for this analysis
Return a copy of the analysis
CurveAnalysis.from_config
(config)Initialize an analysis class from analysis config
CurveAnalysis.run
(experiment_data[, ...])Run analysis and update ExperimentData with analysis result.
CurveAnalysis.set_options
(**fields)Set the analysis options for
run()
method.