How to use the fklearn.training.transformation.custom_transformer function in fklearn

To help you get started, we’ve selected a few fklearn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nubank / fklearn / tests / training / test_transformation.py View on Github external
expected3 = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [1.0, 2.0, 3.0],
        'feat3': [1.5, 2.5, 3.5],
        'target': [1, 4, 9]
    })

    expected4 = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [math.e, math.e ** 2, math.e ** 3],
        'feat3': [1.0, 2.0, 3.0],
        'target': [1, 4, 9]
    })

    transformer_fn, data, log = custom_transformer(input_df, ["feat2"], ln, is_vectorized=True)

    # the transformed input df should contain the square root of the target column
    assert expected3.equals(data)

    transformer_fn, data, log = custom_transformer(input_df, ["feat3"], floor, is_vectorized=True)

    # the transformed input df should contain the squared value of the feat1 column
    assert expected4.equals(data)
github nubank / fklearn / tests / training / test_transformation.py View on Github external
'target': [1.0, 2.0, 3.0]
    })

    expected2 = pd.DataFrame({
        'feat1': [1, 4, 9],
        'feat2': [math.e, math.e ** 2, math.e ** 3],
        'feat3': [1.5, 2.5, 3.5],
        'target': [1, 4, 9]
    })

    transformer_fn, data, log = custom_transformer(input_df, ["target"], sqrt)

    # the transformed input df should contain the square root of the target column
    assert expected.equals(data)

    transformer_fn, data, log = custom_transformer(input_df, ["feat1"], lambda x: x ** 2)

    # the transformed input df should contain the squared value of the feat1 column
    assert expected2.equals(data)

    expected3 = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [1.0, 2.0, 3.0],
        'feat3': [1.5, 2.5, 3.5],
        'target': [1, 4, 9]
    })

    expected4 = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [math.e, math.e ** 2, math.e ** 3],
        'feat3': [1.0, 2.0, 3.0],
        'target': [1, 4, 9]
github nubank / fklearn / tests / training / test_transformation.py View on Github external
expected = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [math.e, math.e ** 2, math.e ** 3],
        'feat3': [1.5, 2.5, 3.5],
        'target': [1.0, 2.0, 3.0]
    })

    expected2 = pd.DataFrame({
        'feat1': [1, 4, 9],
        'feat2': [math.e, math.e ** 2, math.e ** 3],
        'feat3': [1.5, 2.5, 3.5],
        'target': [1, 4, 9]
    })

    transformer_fn, data, log = custom_transformer(input_df, ["target"], sqrt)

    # the transformed input df should contain the square root of the target column
    assert expected.equals(data)

    transformer_fn, data, log = custom_transformer(input_df, ["feat1"], lambda x: x ** 2)

    # the transformed input df should contain the squared value of the feat1 column
    assert expected2.equals(data)

    expected3 = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [1.0, 2.0, 3.0],
        'feat3': [1.5, 2.5, 3.5],
        'target': [1, 4, 9]
    })
github nubank / fklearn / tests / training / test_transformation.py View on Github external
'target': [1, 4, 9]
    })

    expected4 = pd.DataFrame({
        'feat1': [1, 2, 3],
        'feat2': [math.e, math.e ** 2, math.e ** 3],
        'feat3': [1.0, 2.0, 3.0],
        'target': [1, 4, 9]
    })

    transformer_fn, data, log = custom_transformer(input_df, ["feat2"], ln, is_vectorized=True)

    # the transformed input df should contain the square root of the target column
    assert expected3.equals(data)

    transformer_fn, data, log = custom_transformer(input_df, ["feat3"], floor, is_vectorized=True)

    # the transformed input df should contain the squared value of the feat1 column
    assert expected4.equals(data)