|
|
@ -23,9 +23,9 @@ class TestDataset(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
for model in model_instances: |
|
|
|
for model in model_instances: |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
|
|
|
|
model.state = model.get_state(None) |
|
|
|
with self.assertRaises(AssertionError): |
|
|
|
with self.assertRaises(AssertionError): |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
|
|
|
|
|
|
|
|
def test_peak_antisegments(self): |
|
|
|
def test_peak_antisegments(self): |
|
|
|
data_val = [1.0, 1.0, 1.0, 2.0, 3.0, 2.0, 1.0, 1.0, 1.0, 1.0, 5.0, 7.0, 5.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] |
|
|
|
data_val = [1.0, 1.0, 1.0, 2.0, 3.0, 2.0, 1.0, 1.0, 1.0, 1.0, 5.0, 7.0, 5.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] |
|
|
@ -36,7 +36,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.PeakModel() |
|
|
|
model = models.PeakModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -49,7 +50,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -62,7 +64,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.TroughModel() |
|
|
|
model = models.TroughModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -75,7 +78,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.DropModel() |
|
|
|
model = models.DropModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -88,7 +92,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.GeneralModel() |
|
|
|
model = models.GeneralModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -101,7 +106,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -113,8 +119,9 @@ class TestDataset(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.DropModel() |
|
|
|
model = models.DropModel() |
|
|
|
|
|
|
|
model.state = model.get_state(None) |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -125,8 +132,9 @@ class TestDataset(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
|
|
|
|
|
model.state = model.get_state(None) |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -166,7 +174,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
for model in model_instances: |
|
|
|
for model in model_instances: |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -175,78 +184,84 @@ class TestDataset(unittest.TestCase): |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000001, 'to': 1523889000003, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000001, 'to': 1523889000003, 'labeled': True, 'deleted': False}] |
|
|
|
model = models.GeneralModel() |
|
|
|
model = models.GeneralModel() |
|
|
|
model.fit(dataframe, segments,'test', dict()) |
|
|
|
model.state = model.get_state(None) |
|
|
|
|
|
|
|
model.fit(dataframe, segments,'test') |
|
|
|
result = len(data_val) + 1 |
|
|
|
result = len(data_val) + 1 |
|
|
|
for _ in range(2): |
|
|
|
for _ in range(2): |
|
|
|
model.do_detect(dataframe,'test') |
|
|
|
model.do_detect(dataframe) |
|
|
|
max_pattern_index = max(model.do_detect(dataframe, 'test')) |
|
|
|
max_pattern_index = max(model.do_detect(dataframe)) |
|
|
|
self.assertLessEqual(max_pattern_index[0], result) |
|
|
|
self.assertLessEqual(max_pattern_index[0], result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_peak_model_for_cache(self): |
|
|
|
def test_peak_model_for_cache(self): |
|
|
|
cache = { |
|
|
|
cache = { |
|
|
|
'pattern_center': [1, 6], |
|
|
|
'patternCenter': [1, 6], |
|
|
|
'model_peak': [1, 4, 0], |
|
|
|
'patternModel': [1, 4, 0], |
|
|
|
'confidence': 2, |
|
|
|
'confidence': 2, |
|
|
|
'convolve_max': 8, |
|
|
|
'convolveMax': 8, |
|
|
|
'convolve_min': 7, |
|
|
|
'convolveMin': 7, |
|
|
|
'WINDOW_SIZE': 1, |
|
|
|
'windowSize': 1, |
|
|
|
'conv_del_min': 0, |
|
|
|
'convDelMin': 0, |
|
|
|
'conv_del_max': 0, |
|
|
|
'convDelMax': 0, |
|
|
|
|
|
|
|
'heightMax': 4, |
|
|
|
|
|
|
|
'heightMin': 4, |
|
|
|
} |
|
|
|
} |
|
|
|
data_val = [2.0, 5.0, 1.0, 1.0, 1.0, 2.0, 5.0, 1.0, 1.0, 2.0, 3.0, 7.0, 1.0, 1.0, 1.0] |
|
|
|
data_val = [2.0, 5.0, 1.0, 1.0, 1.0, 2.0, 5.0, 1.0, 1.0, 2.0, 3.0, 7.0, 1.0, 1.0, 1.0] |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000012, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000012, 'labeled': True, 'deleted': False}] |
|
|
|
model = models.PeakModel() |
|
|
|
model = models.PeakModel() |
|
|
|
result = model.fit(dataframe, segments, 'test', cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
self.assertEqual(len(result['pattern_center']), 3) |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
|
|
|
|
|
self.assertEqual(len(result.pattern_center), 3) |
|
|
|
|
|
|
|
|
|
|
|
def test_trough_model_for_cache(self): |
|
|
|
def test_trough_model_for_cache(self): |
|
|
|
cache = { |
|
|
|
cache = { |
|
|
|
'pattern_center': [2, 6], |
|
|
|
'patternCenter': [2, 6], |
|
|
|
'pattern_model': [5, 0.5, 4], |
|
|
|
'patternModel': [5, 0.5, 4], |
|
|
|
'confidence': 2, |
|
|
|
'confidence': 2, |
|
|
|
'convolve_max': 8, |
|
|
|
'convolveMax': 8, |
|
|
|
'convolve_min': 7, |
|
|
|
'convolveMin': 7, |
|
|
|
'WINDOW_SIZE': 1, |
|
|
|
'window_size': 1, |
|
|
|
'conv_del_min': 0, |
|
|
|
'convDelMin': 0, |
|
|
|
'conv_del_max': 0, |
|
|
|
'convDelMax': 0, |
|
|
|
} |
|
|
|
} |
|
|
|
data_val = [5.0, 5.0, 1.0, 4.0, 5.0, 5.0, 0.0, 4.0, 5.0, 5.0, 6.0, 1.0, 5.0, 5.0, 5.0] |
|
|
|
data_val = [5.0, 5.0, 1.0, 4.0, 5.0, 5.0, 0.0, 4.0, 5.0, 5.0, 6.0, 1.0, 5.0, 5.0, 5.0] |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000012, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000012, 'labeled': True, 'deleted': False}] |
|
|
|
model = models.TroughModel() |
|
|
|
model = models.TroughModel() |
|
|
|
result = model.fit(dataframe, segments, 'test', cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
self.assertEqual(len(result['pattern_center']), 3) |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
|
|
|
|
|
self.assertEqual(len(result.pattern_center), 3) |
|
|
|
|
|
|
|
|
|
|
|
def test_jump_model_for_cache(self): |
|
|
|
def test_jump_model_for_cache(self): |
|
|
|
cache = { |
|
|
|
cache = { |
|
|
|
'pattern_center': [2, 6], |
|
|
|
'patternCenter': [2, 6], |
|
|
|
'pattern_model': [5, 0.5, 4], |
|
|
|
'patternModel': [5, 0.5, 4], |
|
|
|
'confidence': 2, |
|
|
|
'confidence': 2, |
|
|
|
'convolve_max': 8, |
|
|
|
'convolveMax': 8, |
|
|
|
'convolve_min': 7, |
|
|
|
'convolveMin': 7, |
|
|
|
'WINDOW_SIZE': 1, |
|
|
|
'window_size': 1, |
|
|
|
'conv_del_min': 0, |
|
|
|
'convDelMin': 0, |
|
|
|
'conv_del_max': 0, |
|
|
|
'convDelMax': 0, |
|
|
|
} |
|
|
|
} |
|
|
|
data_val = [1.0, 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 5.0, 5.0, 0.0, 0.0, 4.0, 4.0, 4.0, 4.0] |
|
|
|
data_val = [1.0, 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 5.0, 5.0, 0.0, 0.0, 4.0, 4.0, 4.0, 4.0] |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 152388900009, 'to': 1523889000013, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 152388900009, 'to': 1523889000013, 'labeled': True, 'deleted': False}] |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
|
result = model.fit(dataframe, segments, 'test', cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
self.assertEqual(len(result['pattern_center']), 3) |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
|
|
|
|
|
self.assertEqual(len(result.pattern_center), 3) |
|
|
|
|
|
|
|
|
|
|
|
def test_models_for_pattern_model_cache(self): |
|
|
|
def test_models_for_pattern_model_cache(self): |
|
|
|
cache = { |
|
|
|
cache = { |
|
|
|
'pattern_center': [4, 12], |
|
|
|
'patternCenter': [4, 12], |
|
|
|
'pattern_model': [], |
|
|
|
'patternModel': [], |
|
|
|
'confidence': 2, |
|
|
|
'confidence': 2, |
|
|
|
'convolve_max': 8, |
|
|
|
'convolveMax': 8, |
|
|
|
'convolve_min': 7, |
|
|
|
'convolveMin': 7, |
|
|
|
'WINDOW_SIZE': 2, |
|
|
|
'window_size': 2, |
|
|
|
'conv_del_min': 0, |
|
|
|
'convDelMin': 0, |
|
|
|
'conv_del_max': 0, |
|
|
|
'convDelMax': 0, |
|
|
|
} |
|
|
|
} |
|
|
|
data_val = [5.0, 5.0, 5.0, 5.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 0, 0, 0, 0, 0, 0, 6.0, 6.0, 6.0, 1.0, 1.0, 1.0, 1.0, 1.0] |
|
|
|
data_val = [5.0, 5.0, 5.0, 5.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 0, 0, 0, 0, 0, 0, 6.0, 6.0, 6.0, 1.0, 1.0, 1.0, 1.0, 1.0] |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
@ -254,7 +269,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.DropModel() |
|
|
|
model = models.DropModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.fit(dataframe, segments, 'test', cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
|
|
|
|
model.fit(dataframe, segments, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
self.fail('Model {} raised unexpectedly'.format(model_name)) |
|
|
|
|
|
|
|
|
|
|
@ -267,11 +283,13 @@ class TestDataset(unittest.TestCase): |
|
|
|
2.0, 8.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0] |
|
|
|
2.0, 8.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0] |
|
|
|
data = create_dataframe(problem_data) |
|
|
|
data = create_dataframe(problem_data) |
|
|
|
cache = { |
|
|
|
cache = { |
|
|
|
'pattern_center': [5, 50], |
|
|
|
'patternCenter': [5, 50], |
|
|
|
'pattern_model': [], |
|
|
|
'patternModel': [], |
|
|
|
'WINDOW_SIZE': 2, |
|
|
|
'windowSize': 2, |
|
|
|
'convolve_min': 0, |
|
|
|
'convolveMin': 0, |
|
|
|
'convolve_max': 0, |
|
|
|
'convolveMax': 0, |
|
|
|
|
|
|
|
'convDelMin': 0, |
|
|
|
|
|
|
|
'convDelMax': 0, |
|
|
|
} |
|
|
|
} |
|
|
|
max_ws = 20 |
|
|
|
max_ws = 20 |
|
|
|
iteration = 1 |
|
|
|
iteration = 1 |
|
|
@ -279,14 +297,15 @@ class TestDataset(unittest.TestCase): |
|
|
|
for _ in range(iteration): |
|
|
|
for _ in range(iteration): |
|
|
|
pattern_model = create_random_model(ws) |
|
|
|
pattern_model = create_random_model(ws) |
|
|
|
convolve = scipy.signal.fftconvolve(pattern_model, pattern_model) |
|
|
|
convolve = scipy.signal.fftconvolve(pattern_model, pattern_model) |
|
|
|
cache['WINDOW_SIZE'] = ws |
|
|
|
cache['windowSize'] = ws |
|
|
|
cache['pattern_model'] = pattern_model |
|
|
|
cache['patternModel'] = pattern_model |
|
|
|
cache['convolve_min'] = max(convolve) |
|
|
|
cache['convolveMin'] = max(convolve) |
|
|
|
cache['convolve_max'] = max(convolve) |
|
|
|
cache['convolveMax'] = max(convolve) |
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.GeneralModel() |
|
|
|
model = models.GeneralModel() |
|
|
|
|
|
|
|
model.state = model.get_state(cache) |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.detect(data, 'test', cache) |
|
|
|
model.detect(data, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly with av_model {} and window size {}'.format(model_name, pattern_model, ws)) |
|
|
|
self.fail('Model {} raised unexpectedly with av_model {} and window size {}'.format(model_name, pattern_model, ws)) |
|
|
|
|
|
|
|
|
|
|
@ -294,37 +313,37 @@ class TestDataset(unittest.TestCase): |
|
|
|
data = create_random_model(random.randint(1, 100)) |
|
|
|
data = create_random_model(random.randint(1, 100)) |
|
|
|
data = create_dataframe(data) |
|
|
|
data = create_dataframe(data) |
|
|
|
model_instances = [ |
|
|
|
model_instances = [ |
|
|
|
models.GeneralModel(), |
|
|
|
|
|
|
|
models.PeakModel(), |
|
|
|
models.PeakModel(), |
|
|
|
models.TroughModel() |
|
|
|
models.TroughModel() |
|
|
|
] |
|
|
|
] |
|
|
|
cache = { |
|
|
|
cache = { |
|
|
|
'pattern_center': [5, 50], |
|
|
|
'patternCenter': [5, 50], |
|
|
|
'pattern_model': [], |
|
|
|
'patternModel': [], |
|
|
|
'WINDOW_SIZE': 2, |
|
|
|
'windowSize': 2, |
|
|
|
'convolve_min': 0, |
|
|
|
'convolveMin': 0, |
|
|
|
'convolve_max': 0, |
|
|
|
'convolveMax': 0, |
|
|
|
'confidence': 0, |
|
|
|
'confidence': 0, |
|
|
|
'height_max': 0, |
|
|
|
'heightMax': 0, |
|
|
|
'height_min': 0, |
|
|
|
'heightMin': 0, |
|
|
|
'conv_del_min': 0, |
|
|
|
'convDelMin': 0, |
|
|
|
'conv_del_max': 0, |
|
|
|
'convDelMax': 0, |
|
|
|
} |
|
|
|
} |
|
|
|
ws = random.randint(1, int(len(data['value']/2))) |
|
|
|
ws = random.randint(1, int(len(data['value']/2))) |
|
|
|
pattern_model = create_random_model(ws) |
|
|
|
pattern_model = create_random_model(ws) |
|
|
|
convolve = scipy.signal.fftconvolve(pattern_model, pattern_model) |
|
|
|
convolve = scipy.signal.fftconvolve(pattern_model, pattern_model) |
|
|
|
confidence = 0.2 * (data['value'].max() - data['value'].min()) |
|
|
|
confidence = 0.2 * (data['value'].max() - data['value'].min()) |
|
|
|
cache['WINDOW_SIZE'] = ws |
|
|
|
cache['windowSize'] = ws |
|
|
|
cache['pattern_model'] = pattern_model |
|
|
|
cache['patternModel'] = pattern_model |
|
|
|
cache['convolve_min'] = max(convolve) |
|
|
|
cache['convolveMin'] = max(convolve) |
|
|
|
cache['convolve_max'] = max(convolve) |
|
|
|
cache['convolveMax'] = max(convolve) |
|
|
|
cache['confidence'] = confidence |
|
|
|
cache['confidence'] = confidence |
|
|
|
cache['height_max'] = data['value'].max() |
|
|
|
cache['heightMax'] = data['value'].max() |
|
|
|
cache['height_min'] = confidence |
|
|
|
cache['heightMin'] = confidence |
|
|
|
try: |
|
|
|
try: |
|
|
|
for model in model_instances: |
|
|
|
for model in model_instances: |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model.detect(data, 'test', cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
|
|
|
|
model.detect(data, 'test') |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
self.fail('Model {} raised unexpectedly with dataset {} and cache {}'.format(model_name, data['value'], cache)) |
|
|
|
self.fail('Model {} raised unexpectedly with dataset {} and cache {}'.format(model_name, data['value'], cache)) |
|
|
|
|
|
|
|
|
|
|
|