diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-05-30 17:31:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-30 17:31:17 +0100 |
| commit | 9ad95f7075cf6e03b27207f004fce36909ebbb53 (patch) | |
| tree | 27b6dd7425a19c1cc2d99dc046f46cb9ec55863c /test | |
| parent | use green for testing instead of nose (diff) | |
| download | pygensvm-9ad95f7075cf6e03b27207f004fce36909ebbb53.tar.gz pygensvm-9ad95f7075cf6e03b27207f004fce36909ebbb53.zip | |
Add support for returning the support vectors (#5)
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_core.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test_core.py b/test/test_core.py index 63c172d..ebea89b 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -322,6 +322,23 @@ class GenSVMTestCase(unittest.TestCase): clf = GenSVM(kernel="rbf") clf.fit(X, y, sample_weight=weights) + def test_support_vectors(self): + """ GENSVM: Test getting the support vectors """ + X = np.array( + [[-2, 2], [-2, -2], [-1, 0], [1, 0], [2, 2], [2, -2]] # SV # SV + ) + y = np.array([0, 0, 0, 1, 1, 1]) + clf = GenSVM() + clf.fit(X, y) + SVs = clf.SVs_ + self.assertEqual(SVs[0], 0) + self.assertEqual(SVs[1], 0) + self.assertEqual(SVs[2], 1) + self.assertEqual(SVs[3], 1) + self.assertEqual(SVs[4], 0) + self.assertEqual(SVs[5], 0) + self.assertEqual(clf.n_support_, 2) + if __name__ == "__main__": unittest.main() |
