コード例 #1
0
def test_non_fitted_error(df_vartypes):
    with pytest.raises(NotFittedError):
        transformer = YeoJohnsonTransformer()
        transformer.transform(df_vartypes)
コード例 #2
0
def test_transform_raises_error_if_na_in_df(df_vartypes, df_na):
    # test case 3: when dataset contains na, transform method
    with pytest.raises(ValueError):
        transformer = YeoJohnsonTransformer()
        transformer.fit(df_vartypes)
        transformer.transform(df_na[["Name", "City", "Age", "Marks", "dob"]])
コード例 #3
0
                              verbose=1,
                              patience=10,
                              min_lr=0.01)
early_stop = EarlyStopping(monitor='val_loss',
                           mode='min',
                           min_delta=0,
                           verbose=1,
                           patience=20)

pump_pipeline = Pipeline(
    steps=[("feature_to_keeper",
            pp.FeatureKeeper(variables_to_keep=config.VARIABLES_TO_KEEP)),
           ("missing_imputer",
            pp.MissingImputer(numerical_variables=config.NUMERICAL_VARIABLES)),
           ("yeoJohnson",
            YeoJohnsonTransformer(variables=config.YEO_JHONSON_VARIABLES)),
           ("discretization",
            EqualWidthDiscretiser(bins=5, variables=config.NUMERICAL_VARIABLES)
            ),
           ("categorical_grouper",
            pp.CategoricalGrouping(config_dict=config.VARIABLES_TO_GROUP)),
           ("rareCategories_grouper",
            pp.RareCategoriesGrouping(threshold=config.VARIABLES_THRESHOLD)),
           ("one_hot_encoder",
            OneHotEncoder(variables=config.REAL_CATEGORICAL_VARIABLES,
                          drop_last=False)), ("scaler", MinMaxScaler()),
           ("model",
            KerasClassifier(build_fn=create_model,
                            epochs=1,
                            validation_split=0.2,
                            batch_size=256,
コード例 #4
0
def test_fit_raises_error_if_na_in_df(df_na):
    # test case 2: when dataset contains na, fit method
    with pytest.raises(ValueError):
        transformer = YeoJohnsonTransformer()
        transformer.fit(df_na)
コード例 #5
0
from tests.estimator_checks.estimator_checks import check_feature_engine_estimator
from feature_engine.transformation import (
    BoxCoxTransformer,
    LogCpTransformer,
    ArcsinTransformer,
    LogTransformer,
    PowerTransformer,
    ReciprocalTransformer,
    YeoJohnsonTransformer,
)

_estimators = [
    BoxCoxTransformer(),
    LogTransformer(),
    LogCpTransformer(),
    ArcsinTransformer(),
    PowerTransformer(),
    ReciprocalTransformer(),
    YeoJohnsonTransformer(),
]


@pytest.mark.parametrize("estimator", _estimators)
def test_check_estimator_from_sklearn(estimator):
    return check_estimator(estimator)


@pytest.mark.parametrize("estimator", _estimators[4:])
def test_check_estimator_from_feature_engine(estimator):
    return check_feature_engine_estimator(estimator)