Skip to main content
Version: 0.19.3

Joined feature sets example

from featurestore import *
from featurestore.core.job_types import INGEST
import featurestore.core.transformations as t

# Initialise feature store client
client = Client("ip:port")
client.auth.login()

# Set project specifics
project = client.projects.create("demo")

# Create first feature set
csv = CSVFile("<path to csv file>")
csv_schema = client.extract_schema_from_source(csv)
fs_1 = project.feature_sets.register(csv_schema, "feature_set_1", primary_key=["key"])
fs_1.ingest(csv)

# Create second feature set
snowflake_table = SnowflakeTable("<snowflake account url>", "warehouse name", "database name", "schema name", "table name")
snowflake_table_schema = client.extract_schema_from_source(snowflake_table)
fs_2 = project.feature_sets.register(snowflake_table_schema, "feature_set_2", primary_key=["key"])
fs_2.ingest(snowflake_table)

# Create joined feature set transformation
join_transformation = JoinFeatureSets(left_key = "key", right_key = "key")
input_schema = client.extract_derived_schema([fs_1, fs_2], join_transformation)
joined_fs = project.feature_sets.register(input_schema, "joined_feature_set")

# Get ingest job
val auto_ingest_job = joined_fs.get_active_jobs(INGEST)[0]
auto_ingest_job.wait_for_result()

# Retrieve feature set
ref = joined_fs.retrieve()
ref.download()

Feedback