pyriemann_qiskit.classification.QuanticSVM

class pyriemann_qiskit.classification.QuanticSVM(gamma='scale', C=1.0, max_iter=None, pegasos=False, quantum=True, q_account_token=None, verbose=True, shots=1024, gen_feature_map=<function gen_zz_feature_map.<locals>.<lambda>>, seed=None, use_fidelity_state_vector_kernel=True, use_qiskit_symb=True, n_jobs=4)[source]

Quantum-enhanced SVM classifier

This class implements a support-vector machine (SVM) classifier [1], called SVC, on a quantum machine [2]. Note that if quantum parameter is set to False then a classical SVC will be performed instead.

Notes

Added in version 0.0.1.

Changed in version 0.0.2: Qiskit’s Pegasos implementation [4], [5].

Changed in version 0.1.0: Fix: copy estimator not keeping base class parameters.

Changed in version 0.2.0: Add seed parameter SVC and QSVC now compute probability (may impact performance) Predict is now using predict_proba with a softmax, when using QSVC.

Changed in version 0.3.0: Add use_fidelity_state_vector_kernel parameter

Changed in version 0.4.0: Add n_jobs and use_qiskit_symb parameter for SymbFidelityStatevectorKernel

Changed in version 0.6.0: Migrate to Qiskit 2.x: use BackendSamplerV2 via base class. Moved to pyriemann_qiskit.classification.wrappers.quantic_svm.

Parameters:
  • gamma (float | None, default=None) – Used as input for sklearn rbf_kernel which is used internally. See [3] for more information about gamma.

  • C (float, default=1.0) – Regularization parameter. The strength of the regularization is inversely proportional to C. Must be strictly positive. Note, if pegasos is enabled you may want to consider larger values of C.

  • max_iter (int | None, default=None) – Number of steps in Pegasos or (Q)SVC. If None, respective default values for Pegasos and SVC are used. The default value for Pegasos is 1000. For (Q)SVC it is -1 (that is not limit).

  • pegasos (boolean, default=False) – If true, uses Qiskit’s PegasosQSVC instead of QSVC.

  • quantum (bool, default=True) –

    • If true will run on local or remote backend (depending on q_account_token value),

    • If false, will perform classical computing instead.

  • q_account_token (string | None, default=None) – If quantum is True and q_account_token provided, the classification task will be running on a IBM quantum backend. If load_account is provided, the classifier will use the previous token saved with IBMProvider.save_account().

  • verbose (bool, default=True) – If true, will output all intermediate results and logs.

  • shots (int, default=1024) – Number of repetitions of each circuit, for sampling.

  • gen_feature_map (Callable[[int, str], QuantumCircuit | FeatureMap], default=Callable[int, ZZFeatureMap]) – Function generating a feature map to encode data into a quantum state.

  • seed (int | None, default=None) – Random seed for the simulation

  • use_fidelity_state_vector_kernel (boolean, default=True) – if True, use a FidelitystatevectorKernel for simulation.

  • use_qiskit_symb (boolean, default=True) – This flag is used only if qiskit-symb is installed, and pegasos is False. If True and the number of qubits < 9, then qiskit_symb is used.

  • n_jobs (boolean) – The number of jobs for the qiskit-symb fidelity state vector (if applicable)

See also

QuanticClassifierBase, SymbFidelityStatevectorKernel

References

[2]

V. Havlíček et al., ‘Supervised learning with quantum-enhanced feature spaces’, Nature, vol. 567, no. 7747, pp. 209–212, Mar. 2019, doi: 10.1038/s41586-019-0980-2.

[4]

G. Gentinetta, A. Thomsen, D. Sutter, and S. Woerner, ‘The complexity of quantum support vector machines’, arXiv, arXiv:2203.00031, Feb. 2022. doi: 10.48550/arXiv.2203.00031

[5]

S. Shalev-Shwartz, Y. Singer, and A. Cotter, ‘Pegasos: Primal Estimated sub-GrAdient SOlver for SVM’

__init__(gamma='scale', C=1.0, max_iter=None, pegasos=False, quantum=True, q_account_token=None, verbose=True, shots=1024, gen_feature_map=<function gen_zz_feature_map.<locals>.<lambda>>, seed=None, use_fidelity_state_vector_kernel=True, use_qiskit_symb=True, n_jobs=4)[source]

Examples using pyriemann_qiskit.classification.QuanticSVM

ERP EEG decoding with Quantum Classifier.

ERP EEG decoding with Quantum Classifier.

Use QuanticSVM with real data from Kaggle’s Titanic Dataset

Use QuanticSVM with real data from Kaggle's Titanic Dataset

Suspicious financial activity detection using quantum computer

Suspicious financial activity detection using quantum computer

Comparison with toys datasets.

Comparison with toys datasets.