Product Recommendations
Use case · New dual-data solutions
E-commerce product recommendations
One of the most important features of an e-commerce retail solution is the capability to provide high-quality recommendations for buying other products or items.
A system responsible for this feature is known as a Product Recommendations (PR) system.
A good PR system can significantly increase a website's profits by driving additional product sales to existing customers and by increasing the customer base.
Ultimately, from the end user's point of view, product recommendations provide this type of information:
- Customers who bought this also bought this;
- This product is usually bought together with this;
- These are related recommended products.
-- Which products are most often ordered together with "Chai"?
SELECT p2.product_name, COUNT(o) AS timesTogether
FROM MATCH (p1:product)<-[:orders]-(o:`order`),
(o:`order`)-[:orders]->(p2:product)
WHERE p1.product_name = 'Chai'
GROUP BY p2.product_name
ORDER BY timesTogether DESC
LIMIT 10;
| product_name | timesTogether |
|---|---|
| Boston Crab Meat | 4 |
| Flotemysost | 4 |
| Sir Rodney's Scones | 4 |
| Camembert Pierrot | 4 |
| Tunnbröd | 3 |
See it in CoraDB
Recommendations are graph questions.
“Customers who bought this also bought”, “usually bought together” and “related products” are paths between customers, orders and products. In CoraDB you ask them with a MATCH pattern, on the same data your shop already keeps in tables. These queries run as they are on two of the CoraDB demo databases.
-- Find pairs of customers who like the same product.
SELECT c1.company_name AS customer1, c2.company_name AS customer2, p.name AS product
FROM MATCH
(c1:customer)-[:likes]->(p:product),
(c2:customer)-[:likes]->(p:product)
WHERE c1.id < c2.id;
| customer1 | customer2 | product |
|---|---|---|
| Brown, Roman and Allen | Scott Ltd | Sirop derable |
| Brown, Roman and Allen | Sandoval and Sons | Circe Hooded Ice Fleece |
| Brown, Roman and Allen | Jones, Livingston and Brown | Circe Hooded Ice Fleece |
-- Which other customers have bought at least one of
-- the same products as "Ernst Handel"?
SELECT DISTINCT c2.company_name
FROM MATCH
(c1:customer)-[:purchased]->(o1:`order`),
(o1:`order`)-[:orders]->(p:product),
(p:product)<-[:orders]-(o2:`order`),
(o2:`order`)<-[:purchased]-(c2:customer)
WHERE c1.company_name = 'Ernst Handel'
AND c1 <> c2;
| company_name |
|---|
| Alfreds Futterkiste |
| Ana Trujillo Emparedados y helados |
| Antonio Moreno Taquería |
| Around the Horn |
| B's Beverages |
-- For customers who follow "Nike", show the products it makes,
-- each product's category, and the suppliers carrying them.
SELECT DISTINCT cu.company_name, p.name AS product,
c.name AS category, s.company_name AS supplier
FROM MATCH
(cu:customer)-[:follows]->(b:brand),
(b:brand)-[:manufactures]->(p:product),
(p:product)-[:part_of]->(c:category),
(p:product)-[:available_at]->(s:supplier)
WHERE b.name = 'Nike';
| company_name | product | category | supplier |
|---|---|---|---|
| Adams, Lloyd and Jordan | Aero Daily Fitness Tee | Tees | G'day Mate |
| Adams, Lloyd and Jordan | Bella Tank | Bras & Tanks | Norske Meierier |
| Adams, Lloyd and Jordan | Breathe-Easy Tank | Bras & Tanks | New England Seafood Cannery |
Two types of PR systems, by update frequency:
- Offline systems update recommendation data periodically or on demand.
- Real-time systems use graph databases and parallel processing for instant recommendation updates.
Recommendation systems
Three main models for product recommendation systems:
- Content-based filtering: recommendations rely on product properties (e.g., actor or director) but ignore complex user–product relationships; usually implemented with relational databases.
- Collaborative filtering: recommendations are based on user–item relationships and similarity to other users, accounting for complex connections; typically implemented using a graph database.
- Hybrid models combine content and collaborative filtering for the best results, despite increased complexity.
The usual components of a product recommendation system are:
- An e-commerce relational database (RDBMS).
- A graph database for collaborative PR models and fast complex queries.
- An ETL system that populates the graph database from the relational source. The PR solution therefore needs an ETL tool or module responsible for:
- Populating the graph database;
- Populating specific relational data structures needed for content-based PR models;
- Populating the e-commerce relational database back with the recommendations data.
Real-time systems offer accuracy but face implementation limits due to:
- Capacity constraints.
- Data size limitations.
- High operating costs.
Why CoraDB
- 01
Technology
A top-grade graph database.
Optimized graph algorithms library.
Unified relational and graph database. - 02
Performance
CoraDB handles big data efficiently in both relational and graph engines to ensure fast recommendations.
- 03
Cost advantages
Affordable pricing.
- 04
Team
Experienced database team and consultants.
Our solutions
Create a full e-commerce solution from scratch
The assumption is that you have selected your e-commerce application (such as Magento) and what you need on top of it is a high-quality PR system.
Choose CoraDB as the unified backend: use its relational engine for the core e-commerce solution and content-based filtering, and its graph capabilities for collaborative filtering PR models.
Improve your existing e-commerce solution
- Fully replace your current relational database with CoraDB.
CoraDB is compatible with standard ANSI SQL databases, so the replacement will go smoothly.
Use CoraDB graph database capabilities to implement the PR collaborative filtering models. - Keep your current relational database and your current content-based PR system, and use CoraDB graph database capabilities to implement PR collaborative filtering models.
The main differentiator between CoraDB and other databases is the multi-model capability built into CoraDB.
Having both relational and graph capabilities in the same unified database engine provides important advantages in design, implementation, maintenance, performance, and overall costs.
Current offering
The usual market design for a hybrid model is the following:
CoraDB: simplified, centralized, performant
CoraDB simplifies the hybrid design, boosting performance and easing maintenance by storing all PR data in a single, unpolluted database.
Our services cover all implementation phases:
-
Analysis
We will do a complete analysis of your specific requirements and recommend the methods and algorithms that best fit your needs.
For content-based filtering implementations we will analyze the fit of the most used models, such as vector space models, probabilistic models (Bayes classifiers), decision trees and neural networks.-- Content profile: how many units of each category every customer buys. SELECT cu.company_name AS customer, c.name AS category, SUM(oi.quantity) AS units_bought FROM MATCH (cu:customer), (p:product)-[:part_of]->(c:category), orders o, order_items oi WHERE o.customer_id = cu.id AND oi.order_id = o.id AND oi.product_id = p.id GROUP BY cu.company_name, c.name ORDER BY units_bought DESC LIMIT 10;graph pattern (PGQL)relational tablesOrders and order lines are relational tables; the product categories come from the graph. Result10 rows, first 5 showncustomer category units_bought Kelly Ltd Hoodies & Sweatshirts 125 Young and Sons Tees 120 Kelly Ltd Shorts 114 Young and Sons Performance Fabrics 114 Mayer, Carroll and Owens Shorts 100 For collaborative filtering, the analysis will target the fit of known models such as correlation-based, cosine-based, dimensionality reduction techniques, latent semantic methods, regression, clustering, neural networks, particle filtering and others.
-- Collaborative filtering: products liked by customers who share -- Smith LLC's taste, that Smith LLC does not like yet. SELECT p2.name AS product, COUNT(DISTINCT c2.id) AS similar_customers FROM MATCH (c1:customer)-[:likes]->(p1:product), (c2:customer)-[:likes]->(p1:product), (c2:customer)-[:likes]->(p2:product) WHERE c1.company_name = 'Smith LLC' AND c2.id <> c1.id AND p2.id NOT IN (SELECT p.id FROM MATCH (c:customer)-[:likes]->(p:product) WHERE c.company_name = 'Smith LLC') GROUP BY p2.name ORDER BY similar_customers DESC, product LIMIT 10;graph pattern (PGQL)Three likes edges in one pattern: Smith LLC, the customers who like the same products, and what else they like. Result10 rows, first 5 shownproduct similar_customers Erika Running Short 27 Balboa Persistence Tee 11 Troy Yoga Short 10 Hollister Backyard Sweatshirt 8 Montana Wind Jacket 6 Content filtering
- Memory-based: TF-IDF and cosine similarity
- Model-based: neural networks, Bayesian classifiers
Collaborative filtering
- Memory-based: KNN and cosine similarity
- Model-based: latent factor model
-
Solution architecture and design
Based on the analysis results, we will propose the best solution and build the solution architecture and system design, including the design of the data storage (graph database and relational database, as applicable).
A good solution must address the typical issues of PR systems: cold start, data sparsity, scalability, trust and synonymy. -
Development of the ETL module(s)
For both models, in particular for the collaborative filtering model which requires a graph database back end, we need to select, prepare and load the data needed to run the algorithms (i.e. populate the dedicated graph and relational storage).
This is achieved by implementing an ETL (Extract-Transform-Load) module or application.The ETL solution runs at scheduled periods, or continuously for real-time solutions.
For example, when you scale to big data (millions of entities), an ETL batch process that calculates in parallel the similarities between the entities in scope (such as users and items) is essential for fast response times. -
Product recommendations engine implementation
In this phase we implement the product recommendations engine, using one or several (hybrid) models:
- Collaborative module implementation: graph-based algorithms.
- Content module implementation: relational (or NoSQL) algorithms.
-
Solution maintenance and support
Our product team will ensure proper system functionality, periodic updates, solution improvements and evolution.
As part of the solution, we will also implement tools for specific metrics and efficiency analysis: the quality of a PR system must be measured constantly in order to improve it.
Other scenarios
It is not just users and products that can be used in a recommendation system.
A recommendation system is a more general domain than e-commerce product recommendations: it is any system that provides a recommendation, prediction, opinion, or user-configured list of items that helps the user evaluate items.
The same theory, models, techniques and solutions used for e-commerce PR systems apply in other domains, such as:
- Data mining
- Business intelligence
- Online advertising
- Content recommenders for social media
- Web content recommenders
- Restaurants
- Online dating
- Media streaming
Extra ingredient: ML/AI
Recommendation prediction is inexact and depends on factors such as weather, geography and culture, product description keywords, and fashion trends.
All these influence the quality of the recommendations, measured by the increase in sales volume.
To build a more flexible PR system that learns over time and makes connections the usual models miss, Machine Learning and Artificial Intelligence engines are increasingly added to PR systems.
We can put our rich experience in designing and building ML/AI solutions to work to create new recommendation systems or enhance existing ones.
Summary