SklearnSVM¶
- class SklearnSVM(training_dataset, test_dataset=None, datapoints=None, gamma=None, multiclass_extension=None)[source]¶
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
Attributes
returns class to label
returns label to class
Return a numpy random.
returns result
Methods
SklearnSVM.load_model
(file_path)Load a model from a file path.
SklearnSVM.predict
(data)Predict using the SVM
Execute the classical algorithm.
SklearnSVM.save_model
(file_path)Save the model to a file path.
SklearnSVM.test
(data, labels)Test the SVM
SklearnSVM.train
(data, labels)Train the SVM