SageMaker has emerged as a leading ML platform for enterprises running on AWS. Similarly, Tecton has emerged as the feature store of choice for enterprises running ML in production. Tecton makes it very easy to productionize feature pipelines (the process of transforming raw data into features). This lets you serve polished features for consumption by both data scientists (for training) and models running in production (for inference).
A common question we get is: how can I integrate Tecton’s feature store with SageMaker?
The answer is two fold:
- For model training, data scientists can use Tecton’s SDK within their SageMaker notebooks to retrieve historical features.
- For production models doing online inference, the Tecton feature store integrates with any SageMaker endpoint via Tecton’s low-latency feature serving API.
This guide explains how to use Tecton with Amazon SageMaker. We’ll walk through how you can train and deploy your first model using Tecton without leaving the SageMaker environment.
This is not a comparison between the Tecton and AWS SageMaker feature stores. If you’re looking for that, read our blog on how to choose the right feature store on AWS.
Connecting SageMaker to the Tecton SDK
Tecton’s SDK allows users to interact with Tecton directly via SageMaker notebook instances. For example, a data scientist can quickly fetch training data for a model by calling
Tecton leverages Apache Spark on Amazon EMR to generate very large training data sets. In order to use the Tecton SDK, you’ll need to connect SageMaker to a Tecton-managed EMR cluster. (For more on Tecton and EMR, see this guide).
Fortunately, AWS released an easy integration path for SageMaker and EMR that consists of the following steps:
- Initiate a Cloudformation EMR template
- Create a product for the EMR template in AWS Service Catalog
- Set up and connect to the EMR cluster in SageMaker
A solutions architect at Tecton will provide the necessary CloudFormation template for a Tecton-managed EMR cluster. You can further customize the template by adding bootstrap scripts or using custom AMIs per your organization’s requirements.
After setting up the EMR template in AWS Service Catalog, you’ll just need to connect it to your SageMaker notebook. In the notebook’s SageMaker resources pane, you’ll see a dropdown labeled Clusters. From here, you can view (and, if necessary, create) EMR clusters directly through the SageMaker notebook. You should see the Tecton-managed EMR cluster in the list.
In order to use the Tecton-managed EMR cluster, you’ll need a kernel that has PySpark (SparkMagic) enabled. Follow the instructions here to connect to the cluster. Once connected, you can simply import the Tecton SDK and start working with it.
Understanding the Tecton SDK
In order to understand the SDK methods, it’s important to review the terminology Tecton uses: Data Sources, Transformations, Feature Views, and Feature Services. We’ll describe each briefly. You can find more details in our documentation.
Data Sources: Raw data can either be streaming Data Sources like Kafka and Kinesis, or batch Data Sources like Redshift, Snowflake, Hive tables, and S3.
Transformations: Features are often the result of a transformation that is applied to raw data. For example, aggregations are a common kind of transformation. In Tecton, Transformations can be as simple as a SQL statement, basic Python code, or more complex PySpark code.
Feature Views: A transformation can emit one or more features. The features that result from one transformation are grouped into a Feature View.
Feature Service: A Feature Service is a grouping of Feature Views, and there is a one-to-one relationship between a Feature Service and a model.
Training a Model
In order to train a model, you’ll want to use
get_historical_features from a specific Feature Service. This method requires as input a dataframe that contains entity IDs and timestamps. Tecton will then augment the dataframe with all the features associated with the model, resulting in the data set you need for training.
While the processing of the data is done in Spark, the resulting training data set can be cast to either a Spark or Pandas Dataframe. This provides the flexibility to build models with your framework of choice.
Tecton automatically backfills training data up to a date specified by the user. This is a popular feature with data scientists, as it allows them to develop new features quickly. Tecton also supports “time travel” which allows you to generate training data from historical features with point in time correctness. These capabilities allow us to instantly generate accurate training data with confidence.
Serving Features for Online Inference
For models in production, Tecton supports serving features for real-time inference use cases through a low-latency REST API. We’ve benchmarked our performance and have reliably run 100,000 requests per second. You can use Tecton and SageMaker to deploy a complete ML application in production running real-time inference. Tecton serves the features, and SageMaker hosts the deployed model.
Let’s explore how a simple integration would work, where you have a service that responds to real-time inference requests from your application by sending information to your model and retrieving the results.
- When a real-time inference request comes from your application, your service might optionally make a request to third-party or internal APIs to retrieve additional information.
- Next, your service would make a GetFeatures request to Tecton to retrieve the Feature Vector containing the relevant features for the model.
- Your service passes the Feature Vector retrieved from Tecton to request inferences from the model deployed at your SageMaker endpoint.
Tecton combines production ML capabilities with the convenience of doing everything from within Amazon SageMaker, whether that’s at the development stage for training models or doing real-time inference in production. Generally, Tecton affords you the flexibility of working with the ML frameworks of your choice.
If you’re interested in what Tecton can do for you, we encourage you to reach out for an in-depth demonstration and request a free trial.