예제 #1
0
def test_receive_3D_invalid_shape(caplog):
    node = Pipeline(steps=dummy_transformer, fit=True, mode='transform', meta_label=None)
    node.i_training_0.data = DummyData(start_date=now()).next(5)
    node.update()
    assert node._shape == (5, 5)
    node._status = 3
    node.i_0.data = DummyData(start_date=now()).next(3)
    node.update()
    assert caplog.record_tuples[0][2] == 'Invalid shape'
    assert node._X == None
예제 #2
0
def test_receive_2D_invalid_shape(caplog):
    node = Pipeline(steps=dummy_transformer, fit=True, mode='transform')
    node.i_training.data = DummyData(start_date=now(), num_cols=5).next()
    node.update()
    assert node._shape == 5
    node._status = 3
    node.i.data = DummyData(start_date=now(), num_cols=3).next()
    node.update()
    assert caplog.record_tuples[0][2] == 'Invalid shape'
    assert node._X == None
예제 #3
0
def test_fit_success(caplog):
    caplog.set_level(logging.DEBUG)
    node = Pipeline(steps=dummy_classifier)
    node._status = -1 # bypass accumulation
    assert hasattr(node._pipeline[0], 'n_classes_') == False
    node._X_train = np.array([-1, 1, 1, 1])
    node._y_train = np.array([0, 1, 1, 1])
    node.i_events.data = make_event('training_starts')
    while node._status != 3:
        node.update()
    assert node._pipeline[0].n_classes_ == 2
    assert caplog.record_tuples[0][2] == 'Start training'
    assert caplog.record_tuples[1][2].startswith('Model fitted in')
예제 #4
0
def test_fit_reset(caplog):
    caplog.set_level(logging.DEBUG)
    node = Pipeline(steps=dummy_classifier, event_reset='reset')
    node._status = -1 # bypass accumulation
    node._X_train = np.array([-1, 1, 1, 1])
    node._y_train = np.array([0, 1, 1, 1])
    node.i_events.data = make_event('training_starts')
    node.update()
    node.i_events.data = make_event('reset')
    node.update()
    assert caplog.record_tuples[0][2] == 'Start training'
    assert caplog.record_tuples[1][2] == 'Reset'
    assert node._status == 0
예제 #5
0
def test_trim_3D(random):
    node = Pipeline(steps=dummy_classifier)
    node.i_training_0.data = DummyData(start_date='2018-01-01T00:00:00').next()
    node.i_training_1.data = DummyData(start_date='2018-01-01T00:00:10').next()
    node.i_training_2.data = DummyData(start_date='2018-01-01T00:00:20').next()
    node.i_training_3.data = DummyData(start_date='2018-01-01T00:00:30').next()
    node.i_training_0.meta = { 'epoch': { 'context': { 'target': 1 }}}
    node.i_training_1.meta = { 'epoch': { 'context': { 'target': 2 }}}
    node.i_training_2.meta = { 'epoch': { 'context': { 'target': 3 }}}
    node.i_training_3.meta = { 'epoch': { 'context': { 'target': 4 }}}
    node._accumulation_start = np.datetime64('2017-12-31T00:00:00')
    node._accumulation_stop = np.datetime64('2018-01-01T00:01:00')
    node._status = 1
    node.update()
    node._dimensions = 0 # Bypass accumulation
    start = np.datetime64('2018-01-01T00:00:05')
    stop = np.datetime64('2018-01-01T00:00:25')
    node._accumulate(start, stop)
    assert len(node._X_train_indices) == 2
    assert len(node._X_train) == 2
    assert len(node._y_train) == 2
    assert node._y_train.tolist() == [2, 3]