on-demand-basic-demo(Python)

Loading...

On-demand features - basic demo

This example trains and scores a model that uses an on-demand feature.

The feature parses a JSON string to extract a list of hover times on a webpage. These times are averaged together, and the mean is passed as a feature to a model.

Requirements:

  • A cluster running Databricks Runtime for ML 13.3 LTS or above.
  • The cluster access model must be Single user.

Helper functions and notebook variables

Setup

You can call the Python UDF from SQL, as shown in the next cell.

    Create a TrainingSet with on-demand features

      Log a simple model using the TrainingSet

      For simplicity, this notebook uses a hard-coded model. In practice, you'll log a model trained on the generated TrainingSet.

      Score the model using score_batch

      Serve the Feature Store packaged model

      Wait for the model serving endpoint to be ready.

      Query the endpoint

      Alternatively, use the Serving query endpoints UI to send a request:

      {
        "dataframe_records": [
          {"json_blob": "{\"hover_time\": [5.5, 2.3, 10.3]}"}
        ]
      }
      

      Cleanup