pc.add_feature
pc.add_feature(config, name, type, preprocessing=None)
This is a helper method for adding a feature to a model config.
Parameters:
config: dict
The config to add a feature to.
name: str
The name of the feature to add to the config.
type: str
The type of the feature to add to the config.
preprocessing: dict, default None
An optional preprocessing dictionary to specify preprocessing instructions for this particular feature.
Returns:
None
Examples:
Add a feature to the default config.
dataset = pc.get_dataset("titanic")
config = pc.get_default_config(dataset, targets='Survived')
config
# > {'input_features': [{'name': 'Pclass', 'column': 'Pclass', 'type': 'category'},
# {'name': 'Sex', 'column': 'Sex', 'type': 'category'},
# {'name': 'Age', 'column': 'Age', 'type': 'number'},
# {'name': 'SibSp', 'column': 'SibSp', 'type': 'number'},
# {'name': 'Parch', 'column': 'Parch', 'type': 'category'},
# {'name': 'Fare', 'column': 'Fare', 'type': 'number'},
# {'name': 'Cabin', 'column': 'Cabin', 'type': 'category'},
# {'name': 'Embarked', 'column': 'Embarked', 'type': 'category'}],
# 'output_features': [{'name': 'Survived', 'column': 'Survived', 'type': 'binary'}]}
pc.add_feature(config, "Party", "number", preprocessing={"missing_value_strategy": "fill_with_mean"})
config
# > {'input_features': [{'name': 'Pclass', 'column': 'Pclass', 'type': 'category'},
# {'name': 'Sex', 'column': 'Sex', 'type': 'category'},
# {'name': 'Age', 'column': 'Age', 'type': 'number'},
# {'name': 'SibSp', 'column': 'SibSp', 'type': 'number'},
# {'name': 'Parch', 'column': 'Parch', 'type': 'category'},
# {'name': 'Fare', 'column': 'Fare', 'type': 'number'},
# {'name': 'Cabin', 'column': 'Cabin', 'type': 'category'},
# {'name': 'Embarked', 'column': 'Embarked', 'type': 'category'}
# {'name': 'Party', 'column': 'Party', 'type': 'number', 'preprocessing':{"missing_value_strategy": "fill_with_mean"}}],
# 'output_features': [{'name': 'Survived', 'column': 'Survived', 'type': 'binary'}]}