Driverless AI MOJO example
- Python
- Scala
from featurestore import Client, CSVFile, DriverlessAIMOJO
from featurestore.core.job_types import INGEST
# Initialise feature store client
client = Client("ip:port")
client.auth.login()
# Set project specifics
project = client.projects.create("demo")
# Create a DAI mojo pipeline source
csv = CSVFile("<path to csv data>")
csv_schema = client.extract_schema_from_source(csv)
input_fs = project.feature_sets.register(csv_schema, "input")
input_fs.ingest(csv)
mojo_pipeline = DriverlessAIMOJO("<path to mojo file>")
mojo_pipeline_schema = client.extract_derived_schema([input_fs], mojo_pipeline)
# Register the feature set
my_feature_set = project.feature_sets.register(mojo_pipeline_schema, "feature_set_name", primary_key=["key_name"])
# Get ingest job
auto_ingest_job = my_feature_set.get_active_jobs(INGEST)[0]
auto_ingest_job.wait_for_result()
# Retrieve feature set
ref = my_feature_set.retrieve()
ref.download()
import ai.h2o.featurestore.Client
import ai.h2o.featurestore.core.sources.CSVFile
import ai.h2o.featurestore.core.transformations.DriverlessAIMOJO
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 a DAI mojo pipeline source
val csv = CSVFile("<path to csv data>")
val csvSchema = client.extractSchemaFromSource(csv)
val inputFs = project.featureSets.register(csvSchema, "input")
inputFs.ingest(csv)
val mojoPipeline = DriverlessAIMOJO("<path to mojo file>")
val mojoPipelineSchema = client.extractDerivedSchema(Seq(inputFs), mojoPipeline)
// Register the feature set
val myFeatureSet = project.featureSets.register(mojoPipelineSchema, "featureSetName", primaryKey=Seq("keyName"))
// Get ingest job
val autoIngestJob = myFeatureSet.getActiveJobs(JobTypes.INGEST).head
autoIngestJob.waitForResult()
// Retrieve feature set
val ref = myFeatureSet.retrieve()
ref.download()
Feedback
- Submit and view feedback for this page
- Send feedback about H2O Feature Store to cloud-feedback@h2o.ai