Stay on Top of Emerging Technology Trends
Get updates impacting your industry from our GigaOm Research Community
The beating heart of any business is a reliable and continuous stream of sales. And artificial intelligence is already having a dramatic effect on the bottom line of businesses around the world.
Without a doubt, one of the most effective — and proven — ways to drive sales is to consistently present your prospects and customers with recommendations that are precisely personalized for them.
A task that A.I. is uniquely equipped to excel at.
According to a 2015 study across 1.5 billion ecommerce shopping sessions and 20 different types of recommendations, 11.5% of total revenue was directly attributed to those personalized recommendations.
In fact, A.I.-powered recommendation engines have propelled industry giants like Amazon, Netflix and SoundCloud to the top of their class.
So let’s dive into what it takes to build one of these recommendation engines — for your business.
This guide will step you through configuring an application (originally developed by Martin Kearn of Microsoft) that uses a prediction API to intelligently recommend products — books, specifically.
Looking for an on ramp?
This is a how-to guide intended for developers or tech-savvy business leaders looking for a proven entry point into A.I.-powered business systems.
The End Result
When we’re done, you’ll have a web application that displays all the item-to-item recommendations and frequently bought together recommendations for a given book.
A simple example that highlights two of the most powerful recommendation types.
How can you apply these recommendations to your products and services?
- What You’ll Need
- Step 1: Create the Recommendations API Instance
- Step 2: Upload the Training Data
- Step 3: Create the ‘Item-to-Item Recommendations’ Build
- Step 4: Create the ‘Frequently Bought With’ Build
- Step 5: Launch it!
And without further ado…
What You’ll Need
Before we create the Azure services and model, let’s get the initial requirements knocked out.
Download the source repository.
To start, let’s pull down the source files. (You’ll need a git client installed on your computer for this step.)
Move to the directory you want to use for this demo and run the following commands in a terminal…
# Download source repository
git clone https://github.com/10xNation/microsoft-recommendation-engine.git
The repository includes sample training data and a simple C# application to demo the Recommendations API (and a PHP counterpart).
Create an Azure account.
Go to the Azure home page (Azure is Microsoft’s cloud services platform).
If you don’t already have an Azure account, go ahead and create one by clicking on the “Free Account” button and completing the registration process.
And let’s start spinning up the service.
Step 1: Create the Recommendations API Instance
Go to the Azure Dashboard and sign in with your Azure account.
Click on the “+ New” button.
Then select the “Intelligence + analytics” and “Cognitive Services APIs” options.
Note: This will enable all of the Cognitive Services APIs — Text Analytics, Computer Vision, etc. But for the purposes of this demo, we’re going to stick with the Recommendations API.
On the Cognitive Services API Create page, enter an “Account name” — select a “Subscription,” “API type,” “Location,” and “Pricing tier,” — then create or select a “Resource group.”
- For “API type,” be sure to select “Recommendations API”
- On “Pricing tier,” all we need is the “Free” tier for this demo
Once everything is filled out, hit “Create.”
And after a few minutes, the new subscription will show up on your dashboard. Click it.
Get the subscription key.
That should take you to the Overview tab for your new service.
Click on the “Keys” tab and copy the first key — we’ll need it in the next step.
And now your Recommendations API instance is ready to go, so let’s move on to the training data.
Step 2: Upload the Training Data
Go to the Recommendations API Dashboard.
And sign in with the Cognitive Services key you copied above.
Once you’re logged in, enter a name for your project. e.g.
Books Then hit the “Add Project” button
When the new project is ready, you should see a place to upload a catalog file and usage files.
We’ll start by uploading the catalog file (
book_catalog.csv), which is in the
data directory of the source code you downloaded in What You’ll Need.
Our catalog for this demo is a list of books and their respective details. If you’d like to preview what’s in the catalog, here’s a sample spreadsheet of it.
Once your catalog file is uploaded and processed, it’s time to upload the usage data (
books_usage.csv), which is also in the
In this particular case, the usage data is basically a list of books sales — listing which books were purchased together. If you’d like to preview what’s in the usage data, here’s a sample spreadsheet of it.
Get the model identifier.
We’re going to need the Model ID, so copy it from the model details page.
And that’s it for the training data, so let’s start creating targeted builds.
Step 3: Create the ‘Item-to-Item Recommendations’ Build
The first build we’ll create is for related book recommendations.
More specifically, we’re creating an item-to-item recommendations (I2I) build. Which, given an item or a list of items, it will predict other items that are likely to be of high interest to customers that have interacted with the original set of items.
Click on the “New Build” button to create the build.
This will bring up a settings modal.
And for this build select “Recommendation” for the Build Type and then enter a quick description.
Get the build identifier.
We’re going to need the Build ID for this build, so copy it from the dashboard when ready.
That’s it for this build.
Step 4: Create the ‘Frequently Bought With’ Build
The next build we’ll create is for books that are frequently purchased with another book.
A frequently-bought-together (fbt) build counts the number of times two or three different products are purchased together, and then sorts the sets based on similarity.
Click on “New Build.”
This will bring up another settings modal.
And for this build select “FBT” for the Build Type and then enter a quick description.
Get the build identifier.
We’re going to need the Build ID for this build as well, so copy it from the dashboard when ready.
That’s it for this build as well, so let’s fire up the app.
Step 5: Launch it!
Open up the application in Visual Studio — it’s in the
ms directory of the source code you downloaded in What You’ll Need.
Then open up the
appsettings.json file and enter your respective details:
RecommendationsApiBaseUrl— Make sure the correct Endpoint is listed for your chosen API location from step #1 (it’s listed on the Overview tab)
RecommendationsApiKey— Enter the Cognitive Services API key you copied in step #1
RecommendationsApiModelId— Enter the Model ID you copied in step #2
RecommendationsApiITIBuildId— Enter the Build ID you copied in step #3
RecommendationsApiFBTBuildId— Enter the Build ID you copied in step #4
And then launch the application in IIS Express or your preferred development web server — it may take a few minutes to spin up and display the web page.
Congratulations — you are a recommendations pro!
Click on a book to see the recommendations. Keep in mind this is all sample data — so no guarantees on the relevancy of recommendations.
Play around with the app and API. Have fun!
Now, what will you do will this new tool?
Will you build a new product, enhance an existing one — or startup a completely new business? The sky’s the limit.
You can dig deeper into the Recommendation API — including additional tutorials — in the developer documentation.