on-demand-restaurant-recommendation-demo-online-tables(Python)

Loading...

On-demand features - Restaurant recommendation demo

In this example, a restaurant recommendation model takes a JSON strong containing a user's location and a restaurant id. The restaurant's location is looked up from a pre-materialized feature table published to an online store, and an on-demand feature computes the distance from the user to the restaurant. This distance is passed as input 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.

    Generate and publish feature data

    To access the feature table from Model Serving, you must create an online table.

    Set up Databricks Online Tables

    You can create an online table from the Catalog Explorer UI, Databricks SDK or Rest API. The steps to use Databricks python SDK are described below. For more details, see the Databricks documentation (AWS|Azure). For information about required permissions, see Permissions (AWS|Azure).

    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

      Query the endpoint

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

      {
        "dataframe_records": [
          {
                "restaurant_id": 2,
                "json_blob": "{\"user_x_coord\": 37.79122896768446, \"user_y_coord\": -122.39362610820227}"   
          }
        ]
      }
      

      Cleanup