diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-03-06 12:30:58 -0500 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-03-06 12:30:58 -0500 |
| commit | 99f5421a5ec5906b09c30bf378c449bb423b059e (patch) | |
| tree | 2c80337099e55aebf764447e30728a3a2afc7324 /test_human | |
| parent | Add test for nonlinear training (diff) | |
| download | pygensvm-99f5421a5ec5906b09c30bf378c449bb423b059e.tar.gz pygensvm-99f5421a5ec5906b09c30bf378c449bb423b059e.zip | |
Add script to test interrupts
Diffstat (limited to 'test_human')
| -rw-r--r-- | test_human/interrupt_test.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test_human/interrupt_test.py b/test_human/interrupt_test.py new file mode 100644 index 0000000..f2e926d --- /dev/null +++ b/test_human/interrupt_test.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Test for evaluating interrupted training. + +This test requires human interaction. + +Author: Gertjan van den Burg + +""" + +from gensvm import GenSVM, GenSVMGridSearchCV +from sklearn.datasets import load_iris + + +def wait_for_human(): + print("\nThe goal of this test is to interrupt training using Ctrl+C.") + input("Are you ready to interrupt training? Press enter to continue.") + + +def single(): + wait_for_human() + X, y = load_iris(return_X_y=True) + clf = GenSVM(lmd=1e-10, epsilon=1e-10, p=2, kappa=-0.99, verbose=1) + clf.fit(X, y) + + +def grid(): + wait_for_human() + X, y = load_iris(return_X_y=True) + gg = GenSVMGridSearchCV( + {"p": [1.0, 2.0], "kappa": [1, 2], "lmd": [1e-5]}, verbose=1 + ) + gg.fit(X, y) + + +def main(): + single() + grid() + + +if __name__ == "__main__": + main() |
