Today, data scientists have a wide range of tools available to process and build Machine Learning models. Most of those tools focus on the science around the most common algorithms such as Linear Regression, Logistic Regression among others. And although it seems the science aspect of the process is addressed, things start to get difficult when professionals need to deploy models with Gigabytes or Petabytes of data into production. According to Gartner this is the main reason why Big Data projects fail.
So what are the options to help put your model’s output to production? You must push the model’s results out there, to the real world, say to your own app to show specific products to a cluster of customers who the model predicted are potential buyers for the brand new family plan your telephone service just announced? One way to do this is in python using a flask web service. What is Flask? Flask is a Python micro web server framework that lets you build REST API-based web-services fast with merest configuration hassles. This web service runs on your system locally. You can containerize the flask service using docker, and then run it on a cloud virtual machine. Containerization of a web-server allows you to avoid the trouble of running into environment-related issues. Then you could host the web service container on any cloud platform like AWS or Google Cloud.
In theory, this sounds like a great methodology, but it is just difficult and slow! Let’s describe how the usual process would go: First you need to setup your infrastructure, setup your ELT (Extract, Load, Transform), then you need to run your model with things like Spark and for that you need ML Ops, you will then need to use Airflow and finally build the APIs to send the output to business applications.
In a study conducted by Gartner, it was found that 47% of companies struggle to move projects into production due to difficulties during processes and/or applications.
That means more data scientists and analysts are having trouble tangibilizing their work. As companies evolve, They need to make decisions faster, iterate faster and that means testing the models faster to adjust their decisions.
With Datagran, companies are now able to test and iterate faster to later build core systems. The reason is because Datagran takes care of the ML Ops, Scheduling and APIs. In this tutorial we will go over our REST API and Webhook Actions. Two elements in our set of destinations which companies can use to easily consume or serve the output of ML models in different scenarios.
It’s a handy way to send out information about your company and if you use it proactively, it’s a great way to grow your business.
Unilever– a multinational consumer goods company offering the world’s best-known products like food, confections, energy drinks, baby food, soft drinks, cheese, ice cream, tea, and more, used Datagran’s REST API action to pull the data from their databases and display it in their Salesforce mobile devices.
Here’s how to deploy the results of a Machine Learning model through the REST API action.
REST API tutorial:
First, integrate the data sources you want to extract data from.
Datagran can import data from a wide range of data warehouses and sources, including databases like PostgreSQL, Amazon S3, MongoDB, and more, along with business software including Google Ads, Shopify, Facebook Ads, Salesforce, Segment, Amplitude, and more.
For this example, we will pull several Playground sources with different types of information like Invoice, Client, and Product data. Click here to learn how to integrate data sources into your Datagran account. Secondly, we will train our data with the SQL Operator, and then, we will run an RFM algorithm to predict clusters of customers who we will target with personalized messaging. Now drag and drop the RestAPI element into the canvas.
Press the Edit button.
Select the Source/Operator you want to push out.
Then, select the Table and hit Save.
Now, run the Action by pressing on the Play button located inside of the REST AP element. A green checkmark on the top right-hand side of the element will indicate the element is running.
Hover over the REST API icon on the left menu and click it to view the API Endpoint and parameter.
The parameters displayed here are actual parameters that can be used for the desired request.
Now, you can name and save the pipeline.
Webhook allows you to send real-time data from one application to another whenever a given event occurs. For example, Foodie, sends information to their customers from their app directly to their customers cellphone as SMS and Email once they create an account. It saves a lot of time since it does the backend work that would be gruelingly tedious should it be done manually. Imagine having to send your customer’s information to your email campaign software in order to tell them "Welcome to our company". With Datagran, Webhook takes it much further. Your teams can send machine learning model results to production, be it your app for example, easily without the need to physically build it.
In this example, we’re also using Playground data as shown in the API example above. Drag and drop the Webhook action.
Click the Edit button.
Enter the URL for the endpoint you already should have created.
Choose the table with the data you want to push. You can test if the data is being pushed to your endpoint by pressing the Test button. If everything looks good then you can Save it and head back to the pipeline.
Now, press the play button to run the element. Once the green checkmark lights up, click Run Pipeline.
Datagran effortlessly lets you run ML models, thanks to its pipeline visual editor. You can set up your model, experiment to see the results you get, then connect other data sources and use the same tools to mine that data for predictions that can help you grow your business.
Do you need to make higher-level models? Try out our other Spark algorithms for Regression and Classification, RFM analysis, Recommended Product analysis, and more. For e-commerce businesses, Datagran is a great solution that helps make data actionable with ML pipelines. For more information, read how to increase revenue in your Shopify with ML models using Datagran.