Entities

Feature Store Entities

Overview

Features created via the Feature Store are tied to a specific business entity. Take for example registered users, transactions, or merchants.

A single entity may be related to multiple different feature sets.

Creating an Entity

from qwak.feature_store.entities.entity import Entity

user = Entity(
    name='user_id',
    description='A Registered user entity',
)

Name

The column name that will be used to join the data sources for extraction

πŸ“˜

Naming Conventions

Name is case insensitive - "user" and "User" are considered as the same entity.

Description

User-friendly description of the entity.

Connecting Feature Sets and Entities

We can connect entities and feature sets by using the name of the entity in the feature set entity field.

from qwak.feature_store.feature_sets import batch
from qwak.feature_store.entities.entity import Entity
from qwak.feature_store.feature_sets.transformations import SparkSqlTransformation

user = Entity(
    name='user_id',
    description='A Registered user entity',
)

@batch.feature_set(
    entity="user_id",
    data_sources = {
        "snowflake": ReadPolicy.NewOnly
    })
)
def user_features():
    return SparkSqlTransformation(sql="""
        SELECT user_id,
               registration_country,
               registration_device,
               date_created
        FROM snowflake_users_table
    """)