Online food ordering startups are changing the way the food industry works by making it easier and more convenient than ever to order food online. Such services enable users to select and order a wealth of meal choices from multiple restaurants, either on the web or a mobile app, for takeout and delivery. A few examples include SpoonRocket, Seamless, Hasty, Just Eat, Goldbely, OrderUp, FoodPanda and GrubHub.
By their very nature, online food ordering services obtain rich transactional data related to customers' orders, which reflect their preferences. With all this data collected, why not try and use it to improve the users’ ordering experience? If that sounds like an expensive, time consuming, and calorie-burning undertaking to you, then read on - because this is where PredictionIO comes in.
In this tutorial, we’ll take a closer look at how PredictionIO can help your app personally provide suggestions to users on what they should order.
Analyzing the Use Case
One aspect about the food delivery service industry is that both restaurants and customers are quite regional. This means that some food delivery services serve only a few cities, or perhaps only a single city, and that user behaviors often vary city by city.
Knowing about such differences is important because: 1) you want to only recommend meals to users that can actually be delivered to where they live; and 2) this may necessitate the need for a different predictive model for each city.
With this in mind, one possible solution is to create an independent prediction engine for each city, something that we can quickly do with PredictionIO. This would give us the option to select different algorithm parameters, and even different algorithms, for each city.
With an understanding of the use case, it’s time to turn our attention to modeling. PredictionIO relies upon three core types of data: users, items, and actions. Let’s look at how each of these three data types can be used to model an online food ordering service.
In the case of an online food ordering service, a “user” is a “customer” who is making an order through a web or mobile app. A “user” record requires a user id (uid) string, which is used to uniquely identify a particular user. You are free to assign any value, but it would be more convenient to use the uids which correspond to those already stored in your app database.
An “item”, like a “user”, requires an item id (iid) string to be uniquely identifiable. The term “item” is broad, because it can represent any object in your application that users interact with. In the case of online food ordering services, an “item” most likely represents a meal.
Optionally, an item record can contain one or more category type IDs which are used for classifying the item. In our example below, we’ll use two categories: the city where the meal can be delivered to, and the type of food ordered, such as sushi or pizza. So, for a pizza meal that can be delivered to San Francisco and New York City, it may come with category type IDs “SF”, “NY” and “Pizza”.
The final core data type to consider is an “action” which, as the name suggests, refers to the action by which users interact with an item. PredictionIO has built-in support for common actions such as like, dislike, rate, view, view details, and conversion. In addition to this, you may also add your own custom actions. In our example, we will just make use of three built-in types:
- View action – used when a user browses the information of a meal.
- Conversion action – used when a user orders a meal and completes payment.
- Rate action – used when a user gives a rating to a meal (e.g. on a scale of 1 to 5, 5 being the best).
Personalized Meal Recommendation with PredictionIO
Building this feature with PredictionIO is straightforward:
Step 1: Install PredictionIO Server
Follow the instructions to install PredictionIO.
Step 2: Integrate PredictionIO
Follow the instructions in http://docs.prediction.io/templates/recommendation/quickstart/ to integrate PredictionIO to your application's data collection, and prediction querying stages.
Remember, though, we want to have independent predictive models for every city the food delivery service covers. You can make copies of your engine templates and have each of them point to different sets of data of different cities.
By adding the above code, you have fully integrated PredictionIO into your application, and have built a new feature of providing personalized meal recommendations for your users!
This tutorial has shown you how to build more intelligence into an online food ordering service or app using PredictionIO. By using data the system can learn to provide a more personalized ordering experience for customers. They are presented with more relevant (and hopefully delicious) meal choices which reflect their preferences and are intelligently predicted.
One final note to keep in mind is that the use of PredictionIO doesn’t have to end with just providing meal recommendations to customers. For instance, you might also add "People who buy this meal also buy...." suggestions by using the Similar Product Engine.
Once PredictionIO is hooked to your app, you will be able to predict user preferences, and this can open up a number of possibilities to make your app smarter than ever! Download PredictionIO and try it yourself.