コード例 #1
0
def test_input_and_output_transformer_wrapper_should_not_return_a_different_amount_of_data_inputs_and_expected_outputs(
):
    with pytest.raises(AssertionError):
        p = InputAndOutputTransformerWrapper(ChangeLenDataInputs())
        data_inputs, expected_outputs = _create_data_source((10, 10))

        p.handle_transform(
            DataContainer(data_inputs=data_inputs,
                          expected_outputs=expected_outputs),
            ExecutionContext())
コード例 #2
0
def test_input_and_output_transformer_wrapper_should_fit_with_data_inputs_and_expected_outputs_as_data_inputs(
):
    tape = TapeCallbackFunction()
    p = InputAndOutputTransformerWrapper(FitCallbackStep(tape))
    data_inputs, expected_outputs = _create_data_source((10, 10))

    p.fit(data_inputs, expected_outputs)

    assert np.array_equal(tape.data[0][0][0], data_inputs)
    assert np.array_equal(tape.data[0][0][1], expected_outputs)
コード例 #3
0
def test_input_and_output_transformer_wrapper_should_raise_an_assertion_error_if_current_ids_have_not_been_resampled_correctly(
):
    with pytest.raises(AssertionError) as e:
        p = InputAndOutputTransformerWrapper(
            ChangeLenDataInputsAndExpectedOutputs())
        data_inputs, expected_outputs = _create_data_source((10, 10))

        p.handle_transform(
            DataContainer(data_inputs=data_inputs,
                          expected_outputs=expected_outputs),
            ExecutionContext())
コード例 #4
0
def test_data_doubler():
    p = InputAndOutputTransformerWrapper(DoubleData())
    data_inputs, expected_outputs = _create_data_source((10, 10))

    out = p.handle_transform(
        DataContainer(data_inputs=data_inputs,
                      expected_outputs=expected_outputs), ExecutionContext())

    doubled_length = len(out.data_inputs)
    assert doubled_length == 2 * len(data_inputs)
    assert doubled_length == len(out.expected_outputs)
    assert doubled_length == len(out.current_ids)
コード例 #5
0
def test_input_and_output_transformer_wrapper_should_transform_with_data_inputs_and_expected_outputs(
):
    p = InputAndOutputTransformerWrapper(MultiplyByNInputAndOutput(2))
    data_inputs, expected_outputs = _create_data_source((10, 10))

    data_container = p.handle_transform(
        DataContainer(data_inputs=data_inputs,
                      expected_outputs=expected_outputs), ExecutionContext())

    assert np.array_equal(data_container.data_inputs, data_inputs * 2)
    assert np.array_equal(data_container.expected_outputs,
                          expected_outputs * 2)
コード例 #6
0
def test_fit_transform_input_and_output_transformer_wrapper_with_hashlib_md5_value_hasher():
    step = InputAndOutputTransformerWrapper(WindowTimeSeriesForOutputTransformerWrapper()) \
        .set_hashers([HashlibMd5ValueHasher()])

    step, data_container = step.handle_fit_transform(
        data_container=DataContainer(
            data_inputs=np.array(list(range(10))),
            expected_outputs=np.array(list(range(10)))
        ),
        context=ExecutionContext()
    )

    assert np.array_equal(data_container.data_inputs, np.array(list(range(0, 5))))
    assert np.array_equal(data_container.expected_outputs, np.array(list(range(5, 10))))
コード例 #7
0
def test_input_and_output_transformer_wrapper_should_fit_transform_with_data_inputs_and_expected_outputs(
):
    tape = TapeCallbackFunction()
    p = InputAndOutputTransformerWrapper(
        Pipeline([MultiplyByNInputAndOutput(2),
                  FitCallbackStep(tape)]))
    data_inputs, expected_outputs = _create_data_source((10, 10))

    p, data_container = p.handle_fit_transform(
        DataContainer(data_inputs=data_inputs,
                      expected_outputs=expected_outputs), ExecutionContext())

    assert np.array_equal(data_container.data_inputs, data_inputs * 2)
    assert np.array_equal(data_container.expected_outputs,
                          expected_outputs * 2)
    assert np.array_equal(tape.data[0][0][0], data_inputs * 2)
    assert np.array_equal(tape.data[0][0][1], expected_outputs * 2)