Пример #1
0
 def test_EasyMKL(self):
     self.base_evaluation(algorithms.EasyMKL())
     self.base_evaluation(algorithms.EasyMKL(learner=SVC(C=10)))
     self.base_evaluation(
         algorithms.EasyMKL(learner=algorithms.KOMD(lam=1)))
     self.base_evaluation(
         algorithms.EasyMKL(solver='libsvm', learner=SVC(C=10)))
Пример #2
0
 def test_multiclass_ovo(self):
     mkl = algorithms.EasyMKL(multiclass_strategy='ovo',
                              learner=SVC()).fit(self.KLtr, self.Ytr)
     clf = multiclass.OneVsOneMKLClassifier(mkl).fit(self.KLtr, self.Ytr)
     classes = np.unique(self.Ytr)
     n = len(classes)
     self.assertEqual(len(mkl.solution), (n * (n - 1) / 2))
     c1, c2 = classes[:2]
     self.assertListEqual(clf.solution[(c1, c2)].weights.tolist(),
                          mkl.solution[(c1, c2)].weights.tolist())
Пример #3
0
 def test_parameters(self):
     self.assertRaises(ValueError, algorithms.EasyMKL, lam=2)
     self.assertRaises(ValueError, algorithms.EasyMKL, lam=1.01)
     self.assertRaises(ValueError, algorithms.EasyMKL, lam=-0.1)
     self.assertRaises(ValueError, algorithms.EasyMKL, solver=0.1)
     algorithms.EasyMKL(solver='libsvm', lam=0.2)