aboutsummaryrefslogtreecommitdiff
path: root/test_human/interrupt_test.py
blob: f2e926dcf6552478fa1e796591e1a77f9c9f8b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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()