clf.weights is None if input is multiclass
Opened this issue · 3 comments
Hello, I'm running the testi_training.py, and change the input to a 3-class dataset, and I encounter a problem from these lines:
from MKLpy.algorithms import AverageMKL, EasyMKL, KOMD #KOMD is not a MKL algorithm but a simple kernel machine like the SVM
print ('training AverageMKL...', end='')
clf = AverageMKL().fit(KLtr,Ytr) #a wrapper for averaging kernels
print ('done')
print(clf.weights) #print the weights of the combination of base kernels
K_average = clf.ker_matrix #the combined kernel matrix
the clf.weights and K_average is both None. I'n not sure if clf.weights should be changed to clf.clf.weights, and I don't know what to do with K_average. Is this a bug or is it just the way the algorithm is? Thanks in advance for your kind answer.
Hi,
kernel machines handle multiclass problems by decomposition. Hence, you have several binary problems to solve, and the MKL algorithm learns a different combination for each different binary task (one-vs-one, one-vs-all).
Thus, there is not a global "weights vector", and a global "kernel matrix" as in the case of binary problems.
If you need a deep explanation, I can suggest you this paper:
Ivano Lauriola, Michele Donini, Fabio Aiolli, "Learning Dot Product Polynomials for multiclass problems". Proceedings of the 25th European Symposium of Artificial Neural Networks, Computational Intelligence and Machine Learning (ESANN 2017)
However, thanks for reporting this issue. I'll change this behavior permitting to using clf.weights directly also in multiclass settings.
--Ivano
Thank you for replying so fast! I see it now.
Fixed!
Now in multiclass settings clf.weights returns a dictionary containing weights for each sub-model. The same for clf.ker_matrix