Esempio n. 1
0
def _join_features(numerical_features, numerical_features_valid,
                   categorical_features, categorical_features_valid, config,
                   train_mode, **kwargs):
    if train_mode:
        feature_joiner = Step(name='feature_joiner',
                              transformer=fe.FeatureJoiner(),
                              input_steps=numerical_features +
                              categorical_features,
                              adapter=Adapter({
                                  'numerical_feature_list': [
                                      E(feature.name, 'numerical_features')
                                      for feature in numerical_features
                                  ],
                                  'categorical_feature_list': [
                                      E(feature.name, 'categorical_features')
                                      for feature in categorical_features
                                  ],
                              }),
                              cache_dirpath=config.env.cache_dirpath,
                              **kwargs)

        feature_joiner_valid = Step(
            name='feature_joiner_valid',
            transformer=feature_joiner,
            input_steps=numerical_features_valid + categorical_features_valid,
            adapter=Adapter({
                'numerical_feature_list': [
                    E(feature.name, 'numerical_features')
                    for feature in numerical_features_valid
                ],
                'categorical_feature_list': [
                    E(feature.name, 'categorical_features')
                    for feature in categorical_features_valid
                ],
            }),
            cache_dirpath=config.env.cache_dirpath,
            **kwargs)

        return feature_joiner, feature_joiner_valid

    else:
        feature_joiner = Step(name='feature_joiner',
                              transformer=fe.FeatureJoiner(),
                              input_steps=numerical_features +
                              categorical_features,
                              adapter=Adapter({
                                  'numerical_feature_list': [
                                      E(feature.name, 'numerical_features')
                                      for feature in numerical_features
                                  ],
                                  'categorical_feature_list': [
                                      E(feature.name, 'categorical_features')
                                      for feature in categorical_features
                                  ],
                              }),
                              cache_dirpath=config.env.cache_dirpath,
                              **kwargs)

    return feature_joiner
def _join_features(numerical_features, numerical_features_valid,
                   categorical_features, categorical_features_valid, config,
                   train_mode):
    if train_mode:
        feature_joiner = Step(
            name='feature_joiner',
            transformer=fe.FeatureJoiner(),
            input_steps=numerical_features + categorical_features,
            adapter={
                'numerical_feature_list':
                ([(feature.name, 'numerical_features')
                  for feature in numerical_features], identity_inputs),
                'categorical_feature_list':
                ([(feature.name, 'categorical_features')
                  for feature in categorical_features], identity_inputs),
            },
            cache_dirpath=config.env.cache_dirpath)

        feature_joiner_valid = Step(
            name='feature_joiner_valid',
            transformer=feature_joiner,
            input_steps=numerical_features_valid + categorical_features_valid,
            adapter={
                'numerical_feature_list':
                ([(feature.name, 'numerical_features')
                  for feature in numerical_features_valid], identity_inputs),
                'categorical_feature_list':
                ([(feature.name, 'categorical_features')
                  for feature in categorical_features_valid], identity_inputs),
            },
            cache_dirpath=config.env.cache_dirpath)

        return feature_joiner, feature_joiner_valid

    else:
        feature_joiner = Step(
            name='feature_joiner',
            transformer=fe.FeatureJoiner(),
            input_steps=numerical_features + categorical_features,
            adapter={
                'numerical_feature_list':
                ([(feature.name, 'numerical_features')
                  for feature in numerical_features], identity_inputs),
                'categorical_feature_list':
                ([(feature.name, 'categorical_features')
                  for feature in categorical_features], identity_inputs),
            },
            cache_dirpath=config.env.cache_dirpath)

        return feature_joiner