- class VQC(num_qubits=None, feature_map=None, ansatz=None, loss='cross_entropy', optimizer=None, warm_start=False, quantum_instance=None, initial_point=None, callback=None)¶
Variational quantum classifier.
The variational quantum classifier is a variational algorithm where the measured expectation value is interpreted as the output of a classifier.
Only supports one-hot encoded labels; e.g., data like
[1, 0, 0],
[0, 1, 0],
[0, 0, 1].
Multi-label classification is not supported; e.g., data like
[1, 1, 0],
[0, 1, 1],
[1, 0, 1],
[1, 1, 1].
int]) – The number of qubits for the underlying CircuitQNN. If None, derive from feature_map or ansatz. If neither of those is given, raise exception.
QuantumCircuit]) – The feature map for underlying CircuitQNN. If None, use ZZFeatureMap.
QuantumCircuit]) – The ansatz for the underlying CircuitQNN. If None, use RealAmplitudes.
Loss]) – A target loss function to be used in training. Default is cross entropy.
Optimizer]) – An instance of an optimizer to be used in training. When None defaults to SLSQP.
bool) – Use weights from previous fit to start next fit.
QuantumInstance]) – The quantum instance to execute circuits on.
ndarray]) – Initial point for the optimizer to start from.
None]]) – a reference to a user’s callback function that has two parameters and returns
None. The callback can access intermediate data during training. On each iteration an optimizer invokes the callback and passes current weights as an array and a computed value as a float of the objective function being optimized. This allows to track how well optimization / training process is going on.
QiskitMachineLearningError – Needs at least one out of num_qubits, feature_map or ansatz to be given.
Returns the used ansatz.
Returns the underlying quantum circuit.
Returns the used feature map.
Returns the number of qubits used by ansatz and feature map.
Fit the model to data matrix X and targets y.