AWS
A quick start guide for Featureform on AWS EKS.
This quickstart will walk through creating a few simple features, labels, and a training set using Postgres and Redis. We will use a transaction fraud training set.
- Python 3.7+
Install the Featureform SDK via Pip.
pip install featureform
You can follow our Minikube or Kubernetes deployment guide. This will walk through a simple AWS deployment of Featureform with our quick start Helm chart containing Postgres and Redis.
Install the AWS CLI then run the following command to create an EKS cluster.
eksctl create cluster \
--name featureform \
--version 1.21 \
--region us-east-1 \
--nodegroup-name linux-nodes \
--nodes 1 \
--nodes-min 1 \
--nodes-max 4 \
--with-oidc \
--managed
We'll be installing three Helm Charts: Featureform, the Quickstart Demo, and Certificate Manager.
First we need to add the Helm repositories.
helm repo add featureform https://storage.googleapis.com/featureform-helm/
helm repo add jetstack https://charts.jetstack.io
helm repo update
Now we can install the Helm charts.
helm install certmgr jetstack/cert-manager \
--set installCRDs=true \
--version v1.8.0 \
--namespace cert-manager \
--create-namespace
helm install featureform featureform/featureform \
--set global.publicCert=true \
--set global.localCert=false \
--set global.hostname=$FEATUREFORM_HOST
helm install quickstart featureform/quickstart
We can a self-signed TLS certificate for connecting directly to the load balancer.
Wait until the load balancer has been created. It can be checked using:
kubectl get ingress
When the ingresses have a valid address, we can update the deployment to create the public certificate.
export FEATUREFORM_HOST=$(kubectl get ingress | grep "grpc-ingress" | awk {'print $4'} | column -t)
helm upgrade my-featureform featureform/featureform --set global.hostname=$FEATUREFORM_HOST
We can save and export our self-signed certificate.
kubectl get secret featureform-ca-secret -o=custom-columns=':.data.tls\.crt'| base64 -d > tls.crt
export FEATUREFORM_CERT=$(pwd)/tls.crt
The dashboard is now viewable at your ingress address.
echo $FEATUREFORM_HOST
The Quickstart helm chart creates a Postgres instance with preloaded data, as well as an empty Redis standalone instance. Now that they are deployed, we can write a config file in Python.
definitions.py
import featureform as ff
redis = ff.register_redis(
name = "redis-quickstart",
host="quickstart-redis", # The internal dns name for redis
port=6379,
description = "A Redis deployment we created for the Featureform quickstart"
)
postgres = ff.register_postgres(
name = "postgres-quickstart",
host="quickstart-postgres", # The internal dns name for postgres
port="5432",
user="postgres",
password="password",
database="postgres",
description = "A Postgres deployment we created for the Featureform quickstart"
)
Once we create our config file, we can apply it to our Featureform deployment.
featureform apply definitions.py
We will create a user profile for us, and set it as the default owner for all the following resource definitions.
definitions.py
ff.register_user("featureformer").make_default_owner()
Now we'll register our user fraud dataset in Featureform.
definitions.py
transactions = postgres.register_table(
name = "transactions",
variant = "kaggle",
description = "Fraud Dataset From Kaggle",
table = "Transactions", # This is the table's name in Postgres
)
Next, we'll define a SQL transformation on our dataset.
definitions.py
@postgres.sql_transformation(variant="quickstart")
def average_user_transaction():
"""the average transaction amount for a user """
return "SELECT CustomerID as user_id, avg(TransactionAmount) " \
"as avg_transaction_amt from {{transactions.kaggle}} GROUP BY user_id"
Next, we'll register a passenger entity to associate with a feature and label.
definitions.py
user = ff.register_entity("user")
# Register a column from our transformation as a feature
average_user_transaction.register_resources(
entity=user,
entity_column="user_id",
inference_store=redis,
features=[
{"name": "avg_transactions", "variant": "quickstart", "column": "avg_transaction_amt", "type": "float32"},
],
)
# Register label from our base Transactions table
transactions.register_resources(
entity=user,
entity_column="customerid",
labels=[
{"name": "fraudulent", "variant": "quickstart", "column": "isfraud", "type": "bool"},
],
)
Finally, we'll join together the feature and label into a training set.
definitions.py
ff.register_training_set(
"fraud_training", "quickstart",
label=("fraudulent", "quickstart"),
features=[("avg_transactions", "quickstart")],
)
Now that our definitions are complete, we can apply it to our Featureform instance.
featureform apply definitions.py
Once we have our training set and features registered, we can train our model.
import featureform as ff
client = ff.ServingClient()
dataset = client.training_set("fraud_training", "quickstart")
training_dataset = dataset.repeat(10).shuffle(1000).batch(8)
for row in training_dataset:
print(row.features(), row.label())
We can serve features in production once we deploy our trained model as well.
import featureform as ff
client = ff.ServingClient()
fpf = client.features([("avg_transactions", "quickstart")], {"user": "C1410926"})
# Run features through model
Last modified 18d ago