SklearnSVM¶

class SklearnSVM(training_dataset, test_dataset=None, datapoints=None, gamma=None, multiclass_extension=None)[source]

Bases: qiskit.aqua.algorithms.classical_algorithm.ClassicalAlgorithm

The Sklearn SVM algorithm (classical).

This scikit-learn based SVM algorithm uses a classical approach to experiment with feature map classification problems. See also the quantum classifier QSVM.

Internally, this algorithm will run the binary classification or multiclass classification based on how many classes the data has. If the data has more than 2 classes then a multiclass_extension is required to be supplied. Aqua provides several multiclass_extensions.

Parameters
• training_dataset (Dict[str, ndarray]) – Training dataset.

• test_dataset (Optional[Dict[str, ndarray]]) – Testing dataset.

• datapoints (Optional[ndarray]) – Prediction dataset.

• gamma (Optional[int]) – Used as input for sklearn rbf_kernel which is used internally. See sklearn.metrics.pairwise.rbf_kernel for more information about gamma.

• multiclass_extension (Optional[MulticlassExtension]) – If number of classes is greater than 2 then a multiclass scheme must be supplied, in the form of a multiclass extension.

Raises

AquaError – Multiclass extension not supplied when number of classes > 2

Methods

 load_model Load a model from a file path. predict Predict using the SVM run Execute the classical algorithm. save_model Save the model to a file path. test Test the SVM train Train the SVM

Attributes

class_to_label

returns class to label

label_to_class

returns label to class

random

Return a numpy random.

ret

returns result