|
|
@ -6,6 +6,8 @@ import models |
|
|
|
import random |
|
|
|
import random |
|
|
|
import scipy.signal |
|
|
|
import scipy.signal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from analytic_types.segment import Segment |
|
|
|
|
|
|
|
|
|
|
|
class TestDataset(unittest.TestCase): |
|
|
|
class TestDataset(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
def test_models_with_corrupted_dataframe(self): |
|
|
|
def test_models_with_corrupted_dataframe(self): |
|
|
@ -32,6 +34,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
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}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000003, 'to': 1523889000005, 'labeled': False, 'deleted': True}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000003, 'to': 1523889000005, 'labeled': False, 'deleted': True}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.PeakModel() |
|
|
|
model = models.PeakModel() |
|
|
@ -46,6 +49,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000016, 'labeled': True, 'deleted': False}, |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000016, 'labeled': True, 'deleted': False}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': False, 'deleted': True}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': False, 'deleted': True}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
@ -60,6 +64,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
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}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000003, 'to': 1523889000005, 'labeled': False, 'deleted': True}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000003, 'to': 1523889000005, 'labeled': False, 'deleted': True}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.TroughModel() |
|
|
|
model = models.TroughModel() |
|
|
@ -74,6 +79,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000016, 'labeled': True, 'deleted': False}, |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000010, 'to': 1523889000016, 'labeled': True, 'deleted': False}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': False, 'deleted': True}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': False, 'deleted': True}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.DropModel() |
|
|
|
model = models.DropModel() |
|
|
@ -88,6 +94,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
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}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000003, 'to': 1523889000005, 'labeled': False, 'deleted': True}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000003, 'to': 1523889000005, 'labeled': False, 'deleted': True}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.GeneralModel() |
|
|
|
model = models.GeneralModel() |
|
|
@ -102,6 +109,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000019, 'to': 1523889000025, 'labeled': True, 'deleted': False}, |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000019, 'to': 1523889000025, 'labeled': True, 'deleted': False}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': True, 'deleted': False}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': True, 'deleted': False}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
@ -116,6 +124,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000019, 'to': 1523889000025, 'labeled': True, 'deleted': False}, |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000019, 'to': 1523889000025, 'labeled': True, 'deleted': False}, |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': True, 'deleted': False}] |
|
|
|
{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000002, 'to': 1523889000008, 'labeled': True, 'deleted': False}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.DropModel() |
|
|
|
model = models.DropModel() |
|
|
@ -129,6 +138,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
data_val = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.0, 5.0, 4.0, 5.0, 5.0, 6.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0,3.0,3.0,2.0,7.0,8.0,9.0,8.0,7.0,6.0] |
|
|
|
data_val = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.0, 5.0, 4.0, 5.0, 5.0, 6.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0,3.0,3.0,2.0,7.0,8.0,9.0,8.0,7.0,6.0] |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000007, 'to': 1523889000011, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000007, 'to': 1523889000011, 'labeled': True, 'deleted': False}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
@ -166,6 +176,7 @@ class TestDataset(unittest.TestCase): |
|
|
|
data_val = [1.0, 1.0, 1.0, 1.0, 1.0, 5.0, 2.0, 5.0, 5.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 2.0, 3.0, 4.0, 5.0, 4.0, 2.0, 1.0, 3.0, 4.0] |
|
|
|
data_val = [1.0, 1.0, 1.0, 1.0, 1.0, 5.0, 2.0, 5.0, 5.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 2.0, 3.0, 4.0, 5.0, 4.0, 2.0, 1.0, 3.0, 4.0] |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
dataframe = create_dataframe(data_val) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000004, 'to': 1523889000006, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000004, 'to': 1523889000006, 'labeled': True, 'deleted': False}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
model_instances = [ |
|
|
|
model_instances = [ |
|
|
|
models.GeneralModel(), |
|
|
|
models.GeneralModel(), |
|
|
@ -183,6 +194,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
data_val = [1.0, 2.0, 5.0, 2.0, 1.0, 1.0, 3.0, 6.0, 4.0, 2.0, 1.0, 0, 0] |
|
|
|
data_val = [1.0, 2.0, 5.0, 2.0, 1.0, 1.0, 3.0, 6.0, 4.0, 2.0, 1.0, 0, 0] |
|
|
|
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}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
model = models.GeneralModel() |
|
|
|
model = models.GeneralModel() |
|
|
|
model.state = model.get_state(None) |
|
|
|
model.state = model.get_state(None) |
|
|
|
model.fit(dataframe, segments,'test') |
|
|
|
model.fit(dataframe, segments,'test') |
|
|
@ -209,6 +222,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
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}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
model = models.PeakModel() |
|
|
|
model = models.PeakModel() |
|
|
|
model.state = model.get_state(cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
@ -228,6 +243,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
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}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
model = models.TroughModel() |
|
|
|
model = models.TroughModel() |
|
|
|
model.state = model.get_state(cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
@ -247,6 +264,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
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}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
model = models.JumpModel() |
|
|
|
model = models.JumpModel() |
|
|
|
model.state = model.get_state(cache) |
|
|
|
model.state = model.get_state(cache) |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
|
result = model.fit(dataframe, segments, 'test') |
|
|
@ -266,6 +285,8 @@ class TestDataset(unittest.TestCase): |
|
|
|
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) |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000019, 'to': 1523889000024, 'labeled': True, 'deleted': False}] |
|
|
|
segments = [{'_id': 'Esl7uetLhx4lCqHa', 'analyticUnitId': 'opnICRJwOmwBELK8', 'from': 1523889000019, 'to': 1523889000024, 'labeled': True, 'deleted': False}] |
|
|
|
|
|
|
|
segments = [Segment.from_json(segment) for segment in segments] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|
model = models.DropModel() |
|
|
|
model = models.DropModel() |
|
|
|
model_name = model.__class__.__name__ |
|
|
|
model_name = model.__class__.__name__ |
|
|
|