Use the apply() method to attach objects (feature, entity, data source) to a feature group.
Required Parameter
- object
- Specifies the object to update a feature group.
Example setup
>>> load_example_data('dataframe', ['sales'])
>>> df = DataFrame("sales")
>>> from teradataml import Feature, Entity, DataSource, FeatureGroup
Create the feature.
>>> feature = Feature('sales:Feb', df.Feb)
Create an entity.
>>> entity = Entity('sales:accounts', df.accounts)
Create a data source.
>>> data_source = DataSource('Sales_Data', df)
Create a feature group with name 'sales'.
>>> fg = FeatureGroup('Sales',
... features=feature,
... entity=entity,
... data_source=data_source)
Example 1: Create a new feature for column df.Mar and apply the feature to the feature group
Create a feature.
>>> feature = Feature('sales:Mar', df.Mar)
Register the feature with the feature group.
>>> fg.apply(feature)
True
Get the features from the feature group.
>>> fg.features
[Feature(name=sales:Feb), Feature(name=sales:Mar)]
Example 2: Register the data source with the feature group
>>> load_example_data("dataframe", "admissions_train")
>>> admissions = DataFrame("admissions_train")
>>> admissions_source = DataSource('admissions', admissions)
Register the data source with the feature group.
>>> fg.apply(admissions_source)
True
Get the data source from a feature group.
>>> fg.data_source
DataSource(name=admissions)
Example 3: Register the entity with the feature group
>>> entity = Entity('admissions:accounts', admissions.accounts)
Register the entity with the feature group.
>>> fg.apply(entity)
True