qiskit_noise_learning.analysis.Fit
class qiskit_noise_learning.analysis.Fit(*, model: LinearMap[Hashable, FidelityIndex] | None = None, paths: list[Path] | None = None, instruction_sequences: list[InstructionSequence] | None = None, relations: set[tuple[int, int]] | None = None, _store: dict[type[LeveledData], list[LeveledData | AbsentType | SkippedType]] | None = None)
Bases: object
Container for data at each level of the analysis hierarchy.
The LEVELS represent different stages of processed data. In order, they are:
RawDatacorresponding to bit counts of executed instruction sequences.ObservableDatacorresponding to observables of randomizations of paths that traverse the instruction sequences.AggregatedObservableDatacorresponding to a combination of observables aggregated across randomizations.ModelDatacorresponding to model fit parameters.
Each level holds a history of all values written to it; the current value is always the most recent. New levels start as Absent. Levels bypassed by a stage are marked Skipped.
Example:
result = my_stage.run(my_raw_data)
result.raw_data # current RawData
result.history.raw_data # full write history at the RawData levelParameters
- model – The model to fit. If given, it must be a fidelity model, i.e. a
LinearMapwhose output space is aLogFidelitySpace(seeis_fidelity_model()). - paths – The paths to analyze.
- instruction_sequences – The instruction sequences used in the experiment.
- relations – A pre-computed set of
(path_idx, sequence_idx)tuples indicating which paths are traversed by which instruction sequences.
Raises
TypeError – If model is not None and is not a fidelity model.
__init__
__init__(*, model: LinearMap[Hashable, FidelityIndex] | None = None, paths: list[Path] | None = None, instruction_sequences: list[InstructionSequence] | None = None, relations: set[tuple[int, int]] | None = None, _store: dict[type[LeveledData], list[LeveledData | AbsentType | SkippedType]] | None = None)
Methods
Column 1 | Column 2 |
|---|---|
__init__(*[, model, paths, ...]) | |
copy() | Return a copy preserving the full history at each level. |
plot_qubit_pair_decays(pairs, *[, ...]) | Plot a grid of fidelity decays over qubit pairs, drawn from this fit's data. |
Attributes
Column 1 | Column 2 |
|---|---|
aggregated_observable_data | Current data at the AggregatedObservableData level. |
history | The full write history for each level. |
instruction_sequences | The instruction sequences used in the experiment, or None if not set. |
model | The fidelity model used for design matrix construction. |
model_data | Current data at the ModelData level. |
observable_data | Current data at the ObservableData level. |
paths | The paths to compute observables for. |
raw_data | Current data at the RawData level. |
relations | Path-to-sequence relations, or None if not set. |
copy
copy() → Self
Return a copy preserving the full history at each level.
history
Type: FitHistory
The full write history for each level.
model
Type: LinearMap[Hashable, FidelityIndex] | None
The fidelity model used for design matrix construction.
raw_data
Type: RawData | AbsentType | SkippedType
Current data at the RawData level.
observable_data
Type: ObservableData | AbsentType | SkippedType
Current data at the ObservableData level.
aggregated_observable_data
Type: AggregatedObservableData | AbsentType | SkippedType
Current data at the AggregatedObservableData level.
model_data
Type: ModelData | AbsentType | SkippedType
Current data at the ModelData level.
paths
instruction_sequences
Type: list[InstructionSequence] | None
The instruction sequences used in the experiment, or None if not set.
relations
plot_qubit_pair_decays
plot_qubit_pair_decays(pairs: Sequence[tuple[int, int]], *, observable_type: Literal['raw', 'means', 'both'] | None = None, exponential_fit: bool = False, model_prediction: bool = False, observable_marker_kwargs: Mapping[str, object] | None = None, means_marker_kwargs: Mapping[str, object] | None = None, exponential_fit_line_kwargs: Mapping[str, object] | None = None, model_line_kwargs: Mapping[str, object] | None = None, num_cols: int = 3, noise_site: Mapping[str, Literal['before', 'after']] | None = None, paths: Sequence[Path] | None = None, fragment_depths: Sequence[float] | None = None, title: str | None = None) → InteractiveFigure
Plot a grid of fidelity decays over qubit pairs, drawn from this fit’s data.
One subplot per pair, sharing labels/colors across pairs. Which decays are drawn is controlled by the toggles below; all default to off, so enable the ones you want. A requested decay whose data has not been computed on this fit yet is skipped with a warning.
Parameters
- pairs – The qubit pairs to plot, one subplot each. A pair is unordered –
(1, 0)names the same subplot as(0, 1)– so no pair may be repeated. - observable_type – How to draw the empirical observable data:
"raw"(raw per-randomization scatter),"means"(per-fragment-depth means with error bars),"both", orNone(the default) to omit the empirical points. Uses this fit’sObservableData. - exponential_fit – Whether to draw the fitted exponential decay curve, from this fit’s
AggregatedObservableData(itsfragment_depth == -1fitted parameters). Defaults toFalse. - model_prediction – Whether to draw the model-predicted decay curve, from this fit’s model and
ModelData. Defaults toFalse. - observable_marker_kwargs – Optional
markeroverrides for the raw observable points. - means_marker_kwargs – Optional
markeroverrides for the observable-means points. - exponential_fit_line_kwargs – Optional
lineoverrides for the exponential-fit curve. - model_line_kwargs – Optional
lineoverrides for the model curve. - num_cols – The number of subplot columns; rows are derived from the pair count.
- noise_site – An optional noise-site mapping forwarded to the label formatter (with the default
"formula"label style this yields the compactf^{gate}_{pauli}label). Defaults to the noise site of the fit’s model when it is, or contains, a singlePauliLindbladModel. - paths – The paths to draw across all layers. Defaults to the decay paths found in this fit’s observable/aggregated observable data, falling back to the fit’s own
pathswhen no such data is present. Supply this to draw model-prediction curves for a fit that carries only a model (no observable or aggregated observable data to derive the paths from). - fragment_depths – The fragment-depth range for the curves. Defaults to
0through the largest fragment depth in the empirical data present, or0–10when there is none. - title – An optional figure title.
Returns
The figure with interactive legends.
Raises
- ValueError – If the fit has no model (and hence no gate set) to build labels from, or if
pairsnames the same pair twice. - ImportError – If
matplotlibis not installed.