256 lines
16 KiB
Plaintext
256 lines
16 KiB
Plaintext
---
|
||
title: QuadraticIQDiscriminator (v0.26)
|
||
description: API reference for qiskit.ignis.measurement.QuadraticIQDiscriminator in qiskit v0.26
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.ignis.measurement.QuadraticIQDiscriminator
|
||
---
|
||
|
||
<span id="qiskit-ignis-measurement-quadraticiqdiscriminator" />
|
||
|
||
# qiskit.ignis.measurement.QuadraticIQDiscriminator
|
||
|
||
<Class id="qiskit.ignis.measurement.QuadraticIQDiscriminator" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-ignis/tree/stable/0.6/qiskit/ignis/measurement/discriminator/iq_discriminators.py" signature="QuadraticIQDiscriminator(cal_results, qubit_mask, expected_states=None, standardize=False, schedules=None, discriminator_parameters=None)" modifiers="class">
|
||
Quadratic discriminant analysis discriminator for IQ data.
|
||
|
||
**Parameters**
|
||
|
||
* **cal\_results** (*Union\[*[*Result*](qiskit.result.Result "qiskit.result.Result")*, List\[*[*Result*](qiskit.result.Result "qiskit.result.Result")*]]*) – calibration results, Result or list of Result used to fit the discriminator.
|
||
* **qubit\_mask** (*List\[int]*) – determines which qubit’s level 1 data to use in the discrimination process.
|
||
* **expected\_states** (*List\[str]*) – a list that should have the same length as schedules. All results in cal\_results are used if schedules is None. expected\_states must have the corresponding length.
|
||
* **standardize** (*bool*) – if true the discriminator will standardize the xdata using the internal method \_scale\_data.
|
||
* **schedules** (*Union\[List\[str], List\[*[*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule")*]]*) – The schedules or a subset of schedules in cal\_results used to train the discriminator. The user may also pass the name of the schedules instead of the schedules. If schedules is None, then all the schedules in cal\_results are used.
|
||
* **discriminator\_parameters** (*dict*) – parameters for Sklearn’s LDA.
|
||
|
||
**Raises**
|
||
|
||
**ImportError** – If scikit-learn is not installed
|
||
|
||
### \_\_init\_\_
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.__init__" signature="__init__(cal_results, qubit_mask, expected_states=None, standardize=False, schedules=None, discriminator_parameters=None)">
|
||
**Parameters**
|
||
|
||
* **cal\_results** (*Union\[*[*Result*](qiskit.result.Result "qiskit.result.Result")*, List\[*[*Result*](qiskit.result.Result "qiskit.result.Result")*]]*) – calibration results, Result or list of Result used to fit the discriminator.
|
||
* **qubit\_mask** (*List\[int]*) – determines which qubit’s level 1 data to use in the discrimination process.
|
||
* **expected\_states** (*List\[str]*) – a list that should have the same length as schedules. All results in cal\_results are used if schedules is None. expected\_states must have the corresponding length.
|
||
* **standardize** (*bool*) – if true the discriminator will standardize the xdata using the internal method \_scale\_data.
|
||
* **schedules** (*Union\[List\[str], List\[*[*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule")*]]*) – The schedules or a subset of schedules in cal\_results used to train the discriminator. The user may also pass the name of the schedules instead of the schedules. If schedules is None, then all the schedules in cal\_results are used.
|
||
* **discriminator\_parameters** (*dict*) – parameters for Sklearn’s LDA.
|
||
|
||
**Raises**
|
||
|
||
**ImportError** – If scikit-learn is not installed
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||
| [`__init__`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.__init__ "qiskit.ignis.measurement.QuadraticIQDiscriminator.__init__")(cal\_results, qubit\_mask\[, …]) | **type cal\_results**`Union`\[`Result`, `List`\[`Result`]] |
|
||
| [`add_data`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.add_data "qiskit.ignis.measurement.QuadraticIQDiscriminator.add_data")(result, expected\_states\[, refit, …]) | **type result**`Result` |
|
||
| [`discriminate`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.discriminate "qiskit.ignis.measurement.QuadraticIQDiscriminator.discriminate")(x\_data) | Applies the discriminator to x\_data. |
|
||
| [`fit`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.fit "qiskit.ignis.measurement.QuadraticIQDiscriminator.fit")() | Fits the discriminator using self.\_xdata and self.\_ydata. |
|
||
| [`format_iq_data`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.format_iq_data "qiskit.ignis.measurement.QuadraticIQDiscriminator.format_iq_data")(iq\_data) | Takes IQ data obtained from get\_memory(), applies the qubit mask and formats the data as a list of lists. |
|
||
| [`get_xdata`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.get_xdata "qiskit.ignis.measurement.QuadraticIQDiscriminator.get_xdata")(results, schedule\_type\_to\_get\[, …]) | Retrieves feature data (xdata) for the discriminator. |
|
||
| [`get_ydata`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.get_ydata "qiskit.ignis.measurement.QuadraticIQDiscriminator.get_ydata")(results, schedule\_type\_to\_get\[, …]) | Retrieves the expected states (ydata) for the discriminator. |
|
||
| [`is_calibration`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.is_calibration "qiskit.ignis.measurement.QuadraticIQDiscriminator.is_calibration")(result\_name) | Identify if a name corresponds to a calibration name identified by the regex pattern self.\_cal\_pattern. |
|
||
| [`plot`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.plot "qiskit.ignis.measurement.QuadraticIQDiscriminator.plot")(\[axs, show\_boundary, …]) | Creates a plot of the data used to fit the discriminator. |
|
||
| [`plot_xdata`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.plot_xdata "qiskit.ignis.measurement.QuadraticIQDiscriminator.plot_xdata")(axs, results\[, color]) | Add the relevant IQ data from the Qiskit Result, or list thereof, to the given axes as a scatter plot. |
|
||
|
||
## Attributes
|
||
|
||
| | |
|
||
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
||
| [`expected_states`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.expected_states "qiskit.ignis.measurement.QuadraticIQDiscriminator.expected_states") | Returns the expected states used to train the discriminator. |
|
||
| [`fitted`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.fitted "qiskit.ignis.measurement.QuadraticIQDiscriminator.fitted") | True if the discriminator has been fitted to calibration data. |
|
||
| [`schedules`](#qiskit.ignis.measurement.QuadraticIQDiscriminator.schedules "qiskit.ignis.measurement.QuadraticIQDiscriminator.schedules") | Returns the schedules with which the discriminator was fitted. |
|
||
|
||
### add\_data
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.add_data" signature="add_data(result, expected_states, refit=True, schedules=None)">
|
||
**Parameters**
|
||
|
||
* **result** (`Result`) – a Result containing new data to be used to train the discriminator.
|
||
* **expected\_states** (`List`\[`str`]) – the expected states of the results in result.
|
||
* **refit** (`bool`) – refit the discriminator if True.
|
||
* **schedules** (`Union`\[`List`\[`str`], `List`\[`Schedule`], `None`]) – The schedules or a subset of schedules in cal\_results used to train the discriminator. The user may also pass the name of the schedules instead of the schedules. If schedules is None, then all the schedules in cal\_results are used.
|
||
</Function>
|
||
|
||
### discriminate
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.discriminate" signature="discriminate(x_data)">
|
||
Applies the discriminator to x\_data.
|
||
|
||
**Parameters**
|
||
|
||
**x\_data** (*List\[List\[float]]*) – list of features. Each feature is itself a list.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`str`]
|
||
|
||
**Returns**
|
||
|
||
The discriminated x\_data as a list of labels.
|
||
</Function>
|
||
|
||
### expected\_states
|
||
|
||
<Attribute id="qiskit.ignis.measurement.QuadraticIQDiscriminator.expected_states">
|
||
Returns the expected states used to train the discriminator.
|
||
</Attribute>
|
||
|
||
### fit
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.fit" signature="fit()">
|
||
Fits the discriminator using self.\_xdata and self.\_ydata.
|
||
</Function>
|
||
|
||
### fitted
|
||
|
||
<Attribute id="qiskit.ignis.measurement.QuadraticIQDiscriminator.fitted">
|
||
True if the discriminator has been fitted to calibration data.
|
||
</Attribute>
|
||
|
||
### format\_iq\_data
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.format_iq_data" signature="format_iq_data(iq_data)">
|
||
Takes IQ data obtained from get\_memory(), applies the qubit mask and formats the data as a list of lists. Each sub list is IQ data where the first half of the list is the I data and the second half of the list is the Q data.
|
||
|
||
**Parameters**
|
||
|
||
**iq\_data** (*np.ndarray*) – data obtained from get\_memory().
|
||
|
||
**Return type**
|
||
|
||
`List`\[`List`\[`float`]]
|
||
|
||
**Returns**
|
||
|
||
A list of shots where each entry is a list of IQ points.
|
||
|
||
**Raises**
|
||
|
||
[**PulseError**](qiskit.pulse.PulseError "qiskit.pulse.PulseError") – if the measurement return type is unknown
|
||
</Function>
|
||
|
||
### get\_xdata
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.get_xdata" signature="get_xdata(results, schedule_type_to_get, schedules=None)">
|
||
Retrieves feature data (xdata) for the discriminator.
|
||
|
||
**Parameters**
|
||
|
||
* **results** (`Union`\[`Result`, `List`\[`Result`]]) – the get\_memory() method is used to retrieve the level 1 data. If result is a list of Result, then the first Result in the list that returns the data of schedule (through get\_memory(schedule)) is used.
|
||
* **schedule\_type\_to\_get** (`int`) – use to specify if we should return data corresponding to (`0`) calibration data only (`1`) non-calibration data (`2`) both calibration and non-calibration data
|
||
* **schedules** (`Union`\[`List`\[`str`], `List`\[`Schedule`], `None`]) – Either the names of the schedules or the schedules themselves.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`List`\[`float`]]
|
||
|
||
**Returns**
|
||
|
||
data as a list of features. Each feature is a list.
|
||
|
||
**Raises**
|
||
|
||
[**PulseError**](qiskit.pulse.PulseError "qiskit.pulse.PulseError") – if IQ data could not be found
|
||
</Function>
|
||
|
||
### get\_ydata
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.get_ydata" signature="get_ydata(results, schedule_type_to_get, schedules=None)">
|
||
Retrieves the expected states (ydata) for the discriminator.
|
||
|
||
**Parameters**
|
||
|
||
* **results** (`Union`\[`Result`, `List`\[`Result`]]) – results for which to retrieve the y data (i.e. expected states).
|
||
* **schedule\_type\_to\_get** (`int`) – use to specify if we should return data corresponding to \* 0 calibration data only \* 1 non-calibration data \* 2 both calibration and non-calibration data
|
||
* **schedules** (`Union`\[`List`\[`str`], `List`\[`Schedule`], `None`]) – Either the names of the schedules or the schedules themselves.
|
||
|
||
**Returns**
|
||
|
||
**The y data, i.e. expected states. get\_ydata is designed to produce**
|
||
|
||
y data with the same length as the x data.
|
||
|
||
**Return type**
|
||
|
||
list
|
||
</Function>
|
||
|
||
### is\_calibration
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.is_calibration" signature="is_calibration(result_name)">
|
||
Identify if a name corresponds to a calibration name identified by the regex pattern self.\_cal\_pattern.
|
||
|
||
**Parameters**
|
||
|
||
**result\_name** (`str`) – name of the result to be tested.
|
||
|
||
**Returns**
|
||
|
||
**True if the name of the result indicates that it is a**
|
||
|
||
calibration result.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### plot
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.plot" signature="plot(axs=None, show_boundary=False, show_fitting_data=True, flag_misclassified=False, qubits_to_plot=None, title=True)">
|
||
Creates a plot of the data used to fit the discriminator.
|
||
|
||
**Parameters**
|
||
|
||
* **axs** (*Union\[np.ndarray, axes]*) – the axis to use for the plot. If it is none, the plot method will create its own axis instance. If the number of axis instances provided is less than the number of qubits then only the data for the first len(axs) qubits will be plotted.
|
||
* **show\_boundary** (*bool*) – plot the decision regions if true. Some discriminators may put additional constraints on whether the decision regions are plotted or not.
|
||
* **show\_fitting\_data** (*bool*) – if True the x data and labels used to fit the discriminator are shown in the plot.
|
||
* **flag\_misclassified** (*bool*) – plot the misclassified training data points if true.
|
||
* **qubits\_to\_plot** (*list*) – each qubit in this list will receive its own plot. The qubits in qubits to plot must be in the qubit mask. If qubits\_to\_plot is None then the qubit mask will be used.
|
||
* **title** (*bool*) – adds a title to each subplot with the number of the qubit.
|
||
|
||
**Returns**
|
||
|
||
**A tuple of the form: `(Union[List[axes], axes], figure)`**
|
||
|
||
where the axes object used for the plot as well as the figure handle. The figure handle returned is not None only when the figure handle is created by the discriminator’s plot method.
|
||
|
||
**Return type**
|
||
|
||
tuple
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – If matplotlib is not installed, or there is invalid input
|
||
</Function>
|
||
|
||
### plot\_xdata
|
||
|
||
<Function id="qiskit.ignis.measurement.QuadraticIQDiscriminator.plot_xdata" signature="plot_xdata(axs, results, color=None)">
|
||
Add the relevant IQ data from the Qiskit Result, or list thereof, to the given axes as a scatter plot.
|
||
|
||
**Parameters**
|
||
|
||
* **axs** (*Union\[np.ndarray, axes]*) – the axis to use for the plot. If the number of axis instances provided is less than the number of qubits then only the data for the first len(axs) qubits will be plotted.
|
||
* **results** (*Union\[*[*Result*](qiskit.result.Result "qiskit.result.Result")*, List\[*[*Result*](qiskit.result.Result "qiskit.result.Result")*]]*) – the discriminators get\_xdata will be used to retrieve the x data from the Result or list of Results.
|
||
* **color** (*str*) – color of the IQ points in the scatter plot.
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – If not enough axis instances are provided
|
||
</Function>
|
||
|
||
### schedules
|
||
|
||
<Attribute id="qiskit.ignis.measurement.QuadraticIQDiscriminator.schedules">
|
||
Returns the schedules with which the discriminator was fitted.
|
||
</Attribute>
|
||
</Class>
|
||
|