When I try QSVM over Iris data, it needs multiclass extension, but when I provide it, a following error is returned:

AttributeError                            Traceback (most recent call last)
<ipython-input-18-86cd4e7dd846> in <module>
      3 feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
----> 4 qsvm = QSVM(feature_map, training_input, test_input, multiclass_extension=AllPairs)

d:\anaconda\envs\ai\lib\site-packages\qiskit\aqua\algorithms\classifiers\qsvm\qsvm.py in __init__(self, feature_map, training_dataset, test_dataset, datapoints, multiclass_extension, quantum_instance)
    148         else:
    149             multiclass_extension.set_estimator(_QSVM_Estimator, [feature_map])
--> 150             qsvm_instance = _QSVM_Multiclass(self, multiclass_extension)
    152         self.instance = qsvm_instance

d:\anaconda\envs\ai\lib\site-packages\qiskit\aqua\algorithms\classifiers\qsvm\_qsvm_multiclass.py in __init__(self, qalgo, multiclass_classifier)
     37         super().__init__(qalgo)
     38         self.multiclass_classifier = multiclass_classifier
---> 39         self.multiclass_classifier.params.append(qalgo)
     41     def train(self, data, labels):

AttributeError: type object 'AllPairs' has no attribute 'params'

The code is :

seed = 10598

feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
qsvm = QSVM(feature_map, training_input, test_input, multiclass_extension=AllPairs)

The multiclass code was refactored a little some while ago. Here is a tutorial showing the use of these classifiers with QSVM that works with how things are now that should help https://github.com/qiskit-community/qiskit-community-tutorials/blob/master/machine_learning/qsvm_multiclass.ipynb

You will see you now pass an instance of the multiclass in and no longer have that other setup around the multiclass extension and the algorithm.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.