DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning
  • Accelerating AI Inference With TensorRT
  • AI's Dilemma: When to Retrain and When to Unlearn?
  • Getting Started With GenAI on BigQuery: A Step-by-Step Guide

Trending

  • Blue Skies Ahead: An AI Case Study on LLM Use for a Graph Theory Related Application
  • Concourse CI/CD Pipeline: Webhook Triggers
  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  • Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Using SingleStore as a ML Feature Store

Using SingleStore as a ML Feature Store

SingleStore comes to the Feast

By 
Akmal Chaudhri user avatar
Akmal Chaudhri
DZone Core CORE ·
Feb. 02, 22 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
4.3K Views

Join the DZone community and get the full member experience.

Join For Free

Abstract

This article quickly shows how SingleStore can be used as an online Machine Learning Feature Store with just a few changes to a code example provided on GitHub.

Introduction

Feast (Feature Store) is described as follows:

Feast (Feature Store) is an operational data system for managing and serving machine learning features to models in production. Feast is able to serve feature data to models from a low-latency online store (for real-time prediction) or from an offline store (for scale-out batch scoring or model training).

Figure 1 shows the overall flow with Feast.

Feast architecture

Figure 1. Feast.

Serving models from a low-latency online store is a perfect use case for SingleStore. Let's see how we can achieve this.

To begin with, we need to create a free Managed Service account on the SingleStore website. At the time of writing, the Managed Service account from SingleStore comes with $500 of Credits. This is more than adequate for the case study described in this article.

Create the Database

In our SingleStore Managed Service account, let's use the SQL Editor to create a new database. Call this feast, as follows:

SQL
 
CREATE DATABASE IF NOT EXISTS feast;

Install and Configure Feast

We’ll start by installing Feast, as follows:

Shell
 
pip install feast

Next, let's clone the GitHub repo:

Shell
 
git clone https://github.com/feast-dev/feast-custom-online-store-demo
cd feast-custom-online-store-demo

Now, we'll run the following:

Shell
 
pip install -r requirements.txt

MySQL is the example that is provided for a Custom Online Store. We can adapt this very easily for SingleStore. The example uses MySQL Connector. However, for most Python use cases, SingleStore recommends using PyMySQL. All we need to do is install this, as follows:

Shell
 
pip install PyMySQL

Now, we need to navigate to the following directory:

 
cd feast_custom_online_store

Modify the Example Application

In the file mysql.py we need to make a few minor modifications:

  • Replace import mysql.connector with import pymysql
  • Replace mysql.connector.connect with pymysql.connect
  • Replace all conn.cursor(buffered=True) with conn.cursor()

Next, in the file mysql.py we'll modify the following lines:

Python
 
host=online_store_config.host or "127.0.0.1",
user=online_store_config.user or "root",
password=online_store_config.password,
database=online_store_config.database or "feast",

as follows:

Python
 
host=online_store_config.host or "<TO DO>",
user=online_store_config.user or "admin",
password=online_store_config.password or "<TO DO>",
database=online_store_config.database or "feast",

The <TO DO> for host and password should be replaced with the values obtained from the SingleStore Managed Service when creating a cluster.

Run the Code

We'll navigate back up one directory level and run:

Shell
 
PYTHONPATH=$PYTHONPATH:/$(pwd) feast -c feature_repo apply

The output should look like this:

Shell
 
Registered entity driver_id
Registered feature view driver_hourly_stats
Deploying infrastructure for driver_hourly_stats

Next, we'll run the following:

Shell
 
PYTHONPATH=$PYTHONPATH:/$(pwd) feast -c feature_repo materialize-incremental 2021-08-19T22:29:28

The result should look like this:

Shell
 
Materializing 1 feature views to 2021-08-19 23:29:28+01:00 into the feast_custom_online_store.mysql.MySQLOnlineStore online store.
driver_hourly_stats from 2020-09-28 19:54:28+01:00 to 2021-08-19 23:29:28+01:00:
  0%|                                                                         
|  20%|█████████████                                                    
| 1/5 [00: 40%|██████████████████████████                                       
| 2/5 [00: 60%|███████████████████████████████████████                          
| 3/5 [00: 80%|████████████████████████████████████████████████████             
| 4/5 [00:100%|█████████████████████████████████████████████████████
| 5/5 [00:100%|█████████████████████████████████████████████████████
| 5/5 [00:07<00:00,  1.50s/it]

We have reached the end of the example from the GitHub repo. However, if we look at the Quickstart, we can also find some additional steps to follow and explore.

Summary

This article showed rapid code modifications to the Feast MySQL Custom Online Store so that Feast could be used with SingleStore instead. However, we did not consider any optimizations. For example, it may be better for performance reasons to consider using a ROWSTORE for the database table. We'll discuss using SingleStore as a Feature Store in more detail in future articles.

Machine learning

Published at DZone with permission of Akmal Chaudhri. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning
  • Accelerating AI Inference With TensorRT
  • AI's Dilemma: When to Retrain and When to Unlearn?
  • Getting Started With GenAI on BigQuery: A Step-by-Step Guide

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!