Once features and training sets are registered, they can be served via Featureform's Python API.
Serving for Inference
When a feature is defined, it is materialized into the inference store associated with the definition. If a feature has a timestamp, only its most recent value is stored in the inference store. It can be thought of as a feature cache for inference time.
To serve a feature we initialize a serving client, specify the names and variants of the features we wish to serve, and provide the entity whos feature values to look up. Underneath the hood, Featureform will keep a mapping between a feature's name and variant and the tables that they are actually stored in. This allows user's to stick to the Featureform level of abstraction.
When a training set is defined, it is materialized into the offline store associated with the definition. The label from the training set is zipped with the features to form a point-in-time correct dataset. Once that's complete we can initialize a ServingClient and loop through the our dataset
1
import featureform as ff
2
​
3
client = ff.ServingClient(host)
4
dataset = client.dataset(name, variant)
5
for features, labels in dataset:
6
# Train Model
Copied!
Dataset API
The Dataset API takes inspiration from Tensorflow's Dataset API, and both can be used very similarly.
Repeat
1
import featureform as ff
2
​
3
client = ff.ServingClient(host)
4
for features, labels in client.dataset(name, variant).repeat(5):
5
# Run through 5 epochs of the dataset
Copied!
Shuffle
1
import featureform as ff
2
​
3
client = ff.ServingClient(host)
4
buffer_size =1000
5
for features, labels in client.dataset(name, variant).shuffle(buffer_size):
6
# Run through a shuffled dataset
Copied!
Batch
1
import featureform as ff
2
​
3
client = ff.ServingClient(host)
4
for feature_batch, label_batch in client.dataset(name, variant).batch(8):