示例#1
0
def test_features_analyze_features_transformed_features(
        data_classification_balanced, feature_descriptor, transformed_features
):
    """Testing if creating features properly assigns Transformed flag based on provided transformed_features
    sequence."""
    X, y = data_classification_balanced
    f = Features(X, y, feature_descriptor, transformed_features)

    f.original_dataframe = pd.concat([X, y], axis=1)  # original_dataframe needs to be set up
    actual = f._analyze_features(feature_descriptor)

    for feature in actual.keys():
        if feature in transformed_features:
            assert actual[feature].transformed
        else:
            assert not actual[feature].transformed
示例#2
0
def test_features_analyze_features(data_classification_balanced, feature_descriptor):
    """Testing if .analyze_features() method of Features class returns a dictionary with a correct content"""
    n = NumericalFeature
    c = CategoricalFeature
    expected = {
        "Sex": c,
        "AgeGroup": c,
        "Height": n,
        "Product": c,
        "Price": n,
        "bool": c,
        "Target": c
    }

    X, y = data_classification_balanced
    f = Features(X, y, feature_descriptor)

    f.original_dataframe = pd.concat([X, y], axis=1)  # original_dataframe needs to be set up
    actual = f._analyze_features(feature_descriptor)

    assert isinstance(actual, dict)
    for key, item in expected.items():
        assert isinstance(actual[key], item)