- class PegasosQSVC(quantum_kernel=None, C=1.0, num_steps=1000, precomputed=False, seed=None)¶
This class implements Pegasos Quantum Support Vector Classifier algorithm developed in  and includes overridden methods
SVCsuper-class. This implementation is adapted to work with quantum kernels.
quantum_kernel = QuantumKernel() pegasos_qsvc = PegasosQSVC(quantum_kernel=quantum_kernel) pegasos_qsvc.fit(sample_train, label_train) pegasos_qsvc.predict(sample_test)
- : Shalev-Shwartz et al., Pegasos: Primal Estimated sub-GrAdient SOlver for SVM.
QuantumKernel]) – QuantumKernel to be used for classification. Has to be
Nonewhen a precomputed kernel is used.
float) – Positive regularization parameter. The strength of the regularization is inversely proportional to C. Smaller
Cinduce smaller weights which generally helps preventing overfitting. However, due to the nature of this algorithm, some of the computation steps become trivial for larger
C. Thus, larger
Cimprove the performance of the algorithm drastically. If the data is linearly separable in feature space,
Cshould be chosen to be large. If the separation is not perfect,
Cshould be chosen smaller to prevent overfitting.
int) – number of steps in the Pegasos algorithm. There is no early stopping criterion. The algorithm iterates over all steps.
bool) – a boolean flag indicating whether a precomputed kernel is used. Set it to
Truein case of precomputed kernel.
int]) – a seed for the random number generator
quantum_kernelis passed and
precomputedis set to
True. To use a precomputed kernel,
quantum_kernelhas to be of the
quantum_instanceneither instance of
Returns number of steps in the Pegasos algorithm.
Returns a boolean flag indicating whether a precomputed kernel is used.
Returns quantum kernel
fit(X, y[, sample_weight])
Fit the model according to the given training data.
Perform classification on samples in X.