-
Notifications
You must be signed in to change notification settings - Fork 0
/
seco_line_profiling.py
31 lines (26 loc) · 1016 Bytes
/
seco_line_profiling.py
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
import warnings
from line_profiler import LineProfiler
from sklearn_seco import SimpleSeCoEstimator
from sklearn_seco.common import match_rule, RuleContext
from sklearn_seco.tests import conftest
def tcn2(dataset):
with warnings.catch_warnings():
from _pytest.deprecated import RemovedInPytest4Warning
warnings.simplefilter("ignore", RemovedInPytest4Warning)
est = SimpleSeCoEstimator()
est.fit(dataset.x_train, dataset.y_train)
ypred = est.predict(dataset.x_test)
from sklearn.metrics import classification_report, confusion_matrix
print(confusion_matrix(dataset.y_test, ypred))
print(classification_report(dataset.y_test, ypred))
try:
from numba import NumbaWarning
warnings.simplefilter("error", NumbaWarning)
except ImportError:
pass
profile = LineProfiler()
profile.add_function(match_rule)
profile.add_function(RuleContext._count_matches)
profile.add_function(RuleContext.pn)
profile.run('tcn2(conftest.sklearn_make_moons())')
profile.print_stats()