qiskit.ignis.measurement.QuadraticIQDiscriminator¶

class
QuadraticIQDiscriminator
(cal_results, qubit_mask, expected_states=None, standardize=False, schedules=None, discriminator_parameters=None)[código fonte]¶ Quadratic discriminant analysis discriminator for IQ data.
 Parâmetros
cal_results (Union[Result, List[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]]) – 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.
 Levanta
ImportError – If scikitlearn is not installed

__init__
(cal_results, qubit_mask, expected_states=None, standardize=False, schedules=None, discriminator_parameters=None)[código fonte]¶  Parâmetros
cal_results (Union[Result, List[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]]) – 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.
 Levanta
ImportError – If scikitlearn is not installed
Methods
__init__
(cal_results, qubit_mask[, …]) type cal_results
Union
[Result
,List
[Result
]]
add_data
(result, expected_states[, refit, …]) type result
Result
discriminate
(x_data)Applies the discriminator to x_data.
fit
()Fits the discriminator using self._xdata and self._ydata.
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
(results, schedule_type_to_get[, …])Retrieves feature data (xdata) for the discriminator.
get_ydata
(results, schedule_type_to_get[, …])Retrieves the expected states (ydata) for the discriminator.
is_calibration
(result_name)Identify if a name corresponds to a calibration name identified by the regex pattern self._cal_pattern.
plot
([axs, show_boundary, …])Creates a plot of the data used to fit the discriminator.
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
Returns the expected states used to train the discriminator.
True if the discriminator has been fitted to calibration data.
Returns the schedules with which the discriminator was fitted.

add_data
(result, expected_states, refit=True, schedules=None)¶  Parâmetros
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.

discriminate
(x_data)[código fonte]¶ Applies the discriminator to x_data.
 Parâmetros
x_data (List[List[float]]) – list of features. Each feature is itself a list.
 Tipo de retorno
List
[str
] Retorna
The discriminated x_data as a list of labels.

property
expected_states
¶ Returns the expected states used to train the discriminator.

fit
()[código fonte]¶ Fits the discriminator using self._xdata and self._ydata.

property
fitted
¶ True if the discriminator has been fitted to calibration data.

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.
 Parâmetros
iq_data (np.ndarray) – data obtained from get_memory().
 Tipo de retorno
List
[List
[float
]] Retorna
A list of shots where each entry is a list of IQ points.
 Levanta
PulseError – if the measurement return type is unknown

get_xdata
(results, schedule_type_to_get, schedules=None)¶ Retrieves feature data (xdata) for the discriminator.
 Parâmetros
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
) noncalibration data (2
) both calibration and noncalibration dataschedules (
Union
[List
[str
],List
[Schedule
],None
]) – Either the names of the schedules or the schedules themselves.
 Tipo de retorno
List
[List
[float
]] Retorna
data as a list of features. Each feature is a list.
 Levanta
PulseError – if IQ data could not be found

get_ydata
(results, schedule_type_to_get, schedules=None)¶ Retrieves the expected states (ydata) for the discriminator.
 Parâmetros
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 noncalibration data * 2 both calibration and noncalibration dataschedules (
Union
[List
[str
],List
[Schedule
],None
]) – Either the names of the schedules or the schedules themselves.
 Retorna
 The y data, i.e. expected states. get_ydata is designed to produce
y data with the same length as the x data.
 Tipo de retorno
list

is_calibration
(result_name)¶ Identify if a name corresponds to a calibration name identified by the regex pattern self._cal_pattern.
 Parâmetros
result_name (
str
) – name of the result to be tested. Retorna
 True if the name of the result indicates that it is a
calibration result.
 Tipo de retorno
bool

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.
 Parâmetros
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.
 Retorna
 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.
 A tuple of the form:
 Tipo de retorno
tuple
 Levanta
QiskitError – If matplotlib is not installed, or there is invalid input

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.
 Parâmetros
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, List[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.
 Levanta
QiskitError – If not enough axis instances are provided

property
schedules
¶ Returns the schedules with which the discriminator was fitted.