From 3ed51bb4ac5db6dfec92d10d6e302381c27849c8 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Wed, 6 Mar 2019 22:28:49 -0500 Subject: Add support for specifying sample weights (fixes #2) --- test/test_core.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/test_core.py b/test/test_core.py index dcc72bf..af4bb2a 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -291,6 +291,20 @@ class GenSVMTestCase(unittest.TestCase): self.assertLess(abs(V[3, 1] - 0.6547924025329720), eps) self.assertLess(abs(V[3, 2] - -0.6773346708737853), eps) + def test_fit_with_weights(self): + """ GENSVM: Test fit with sample weights """ + X, y = load_iris(return_X_y=True) + weights = np.random.random((X.shape[0],)) + clf = GenSVM() + clf.fit(X, y, sample_weight=weights) + # with seeding + V = clf.combined_coef_ + weights = np.random.random((X.shape[0],)) + clf.fit(X, y, sample_weight=weights, seed_V=V) + + clf = GenSVM(kernel="rbf") + clf.fit(X, y, sample_weight=weights) + if __name__ == "__main__": unittest.main() -- cgit v1.2.3