Skip to content

Online API#

The Feature View provides an Online API to return an individual feature vector, or a batch of feature vectors, containing the latest feature values. To retrieve a feature vector, a client provides the feature view's serving keys. The serving keys are the foreign keys of the feature view's label feature group; a feature view does not have a primary key of its own. For example, if a feature view is built from the customer_profile and customer_purchases feature groups joined on customer_id, then customer_id is the serving key you provide to retrieve a feature vector.

Feature Vectors#

A feature vector is a row of features (without the primary key(s) and event timestamp):

In [1]: fv.get_feature_vector( entry={"location_id": "9844-3333"}, passed_features={"pressure": 1013}, ) lookup online store + passed from client ODT on-demand MDT model-dep return list · no key lookup(entry) → temperature=12.45, rainfall=44 lookup merge(passed_features) → pressure=1013 passed pressure = normalize_pressure(pressure) → 0.50 odt min_max_scaler([temperature, rainfall, pressure]) → [0.31, 0.87, 0.42] mdt [temperature, rainfall, pressure] # location_id stays in the request return Out[1]: [ null, null, null ] the order is fixed: ODT before MDT, MDT always last

It may be the case that for any given feature vector, not all features will come pre-engineered from the feature store. Some features will be provided by the client (or at least the raw data to compute the feature will come from the client). We call these 'passed' features and, similar to precomputed features from the feature store, they can also be transformed by the Hopsworks client in the method:

feature_view.get_feature_vector(entry, passed_features={"pressure": 1013})

When you call get_feature_vector, Hopsworks builds the vector in a fixed order:

  1. retrieve the precomputed features from the online store using the serving keys,
  2. merge in any passed features,
  3. compute on-demand transformations (ODTs),
  4. compute model-dependent transformations (MDTs),
  5. drop the index and helper columns,
  6. return the feature vector.

This ordering is the composition constraint: on-demand transformations run before model-dependent ones, which are always last, just before the model is called.