Joined feature sets example
- Python
- Scala
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()
import ai.h2o.featurestore.Client
import ai.h2o.featurestore.core.sources.{CSVFile, SnowflakeTable}
import ai.h2o.featurestore.core.transformations.JoinFeatureSets
import ai.h2o.featurestore.core.JobTypes
// Initialise feature store client
val client = Client("url")
client.auth.login()
// Set project specifics
val project = client.projects.create("demo")
// Create first feature set
val csv = CSVFile("<path to csv file>")
val csvSchema = client.extractSchemaFromSource(csv)
val fs1 = project.featureSets.register(csvSchema, "featureSet1", primaryKey=Seq("key"))
fs1.ingest(csv)
// Create second feature set
val snowflakeTable = SnowflakeTable("<snowflake account url>", "warehouse name", "database name", "schema name", "table name")
val snowflakeTableSchema = client.extractSchemaFromSource(snowflakeTable)
val fs2 = project.featureSets.register(snowflakeTableSchema, "featureSet2", primaryKey=Seq("key"))
fs2.ingest(snowflakeTable)
// Create joined feature set transformation
val joinTransformation = JoinFeatureSets(leftKey = "key", rightKey = "key")
val inputSchema = client.extractDerivedSchema(Seq(fs1, s2), joinTransformation)
val joinedFs = project.featureSets.register(inputSchema, "joined_feature_set")
// Get ingest job
val autoIngestJob = myFeatureSet.getActiveJobs(JobTypes.INGEST).head
autoIngestJob.waitForResult()
// Retrieve feature set
val ref = joinedFs.retrieve()
ref.download()
Feedback
- Submit and view feedback for this page
- Send feedback about H2O Feature Store to cloud-feedback@h2o.ai