Serving
src.featureform.serving.ServingClient
The serving client is used to retrieve training sets and features for training and serving purposes.
Using the Serving Client:
import featureform as ff
from featureform import ServingClient
client = ServingClient(host="localhost:8000")
# example:
dataset = client.training_set("fraud_training", "quickstart")
training_dataset = dataset.repeat(10).shuffle(1000).batch(8)
for feature_batch in training_dataset:
# Train model
Source code in src/featureform/serving.py
__init__(host=None, local=False, insecure=False, cert_path=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host |
str
|
The hostname of the Featureform instance. Exclude if using Localmode. |
None
|
local |
bool
|
True if using Localmode. |
False
|
insecure |
bool
|
True if connecting to an insecure Featureform endpoint. False if using a self-signed or public TLS certificate |
False
|
cert_path |
str
|
The path to a public certificate if using a self-signed certificate. |
None
|
Source code in src/featureform/serving.py
features(features, entities, model=None)
Returns the feature values for the specified entities.
Examples:
client = ff.ServingClient(local=True)
fpf = client.features([("avg_transactions", "quickstart")], {"user": "C1410926"})
# Run features through model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features |
list[str, str], list[str]
|
List of Name Variant Tuples |
required |
entities |
dict
|
Dictionary of entity name/value pairs |
required |
Returns:
Name | Type | Description |
---|---|---|
features |
numpy.Array
|
An Numpy array of feature values in the order given by the inputs |
Source code in src/featureform/serving.py
training_set(name, variant='default', include_label_timestamp=False, model=None)
Return an iterator that iterates through the specified training set.
Examples:
client = ff.ServingClient()
dataset = client.training_set("fraud_training", "quickstart")
training_dataset = dataset.repeat(10).shuffle(1000).batch(8)
for feature_batch in training_dataset:
# Train model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of training set to be retrieved |
required |
variant |
str
|
Variant of training set to be retrieved |
'default'
|
Returns:
Type | Description |
---|---|
training set (Dataset): A training set iterator |
Source code in src/featureform/serving.py
src.featureform.serving.Dataset
Source code in src/featureform/serving.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
|
__init__(stream, dataframe=None)
Repeats the Dataset for the specified number of times
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stream |
Iterator
|
An iterable object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
Dataset
|
Returns a Dataset created from the iterable object. |
Source code in src/featureform/serving.py
batch(batch_size)
Creates a batch row in the Dataset.
Examples:
client = ff.ServingClient()
dataset = client.training_set("fraud_training", "quickstart")
training_dataset = dataset.batch(8) # Creates a batch of 8 Datasets for each row
for feature_batch in training_dataset:
# Train model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
int
|
The number of items to be added to each batch |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
Dataset
|
Returns the current Dataset |
Source code in src/featureform/serving.py
repeat(num)
Repeats the Dataset for the specified number of times
Examples:
client = ff.ServingClient()
dataset = client.training_set("fraud_training", "quickstart")
training_dataset = dataset.repeat(10) # Repeats data 10 times
for feature_batch in training_dataset:
# Train model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num |
int
|
The number of times the dataset will be repeated |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
Dataset
|
Returns the current Dataset |
Source code in src/featureform/serving.py
shuffle(buffer_size)
Swaps random rows within the Dataset.
Examples:
client = ff.ServingClient()
dataset = client.training_set("fraud_training", "quickstart")
training_dataset = dataset.shuffle(100) # Swaps 100 Rows
for feature_batch in training_dataset:
# Train model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buffer_size |
int
|
The number of Dataset rows to be randomly swapped |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
Dataset
|
Returns the current Dataset |