Recommendation System
aka suggestion system and market basket analysis
Market basket analysis is a type of recommendation system used to analyze the basket/cart of users and learn from their past buying and orders and suggests similar products to the user
This tutorial is divided into two sections
- basics of the recommendation system
- implementation with python.
1. Basics
definition:- When a machine learns through its past experience and returns the output which is most likely to be selected is called recommender machine.
It learns from some independent features of a user and returns output similar or nearest to the decision of the user.
1.1 Types of Recommendation system
1-> Collaborative
- Analyzing data about customers identify patterns
- Suggests to a class of users
- products are suggested to a similar class of users, products might not have any relations between them, but a particular class of customers buy them together.
- example- if some users buy ‘tea’ and ‘biscuits’ together machine will relate tea and biscuits to a particular class of users, say class A, next time if our machine successfully detects that a user is of class A and he is looking for tea, biscuits will also be suggested to the user.
2-> Content-based
- Filter on features of items
- Suggests to similar items
- Products are suggested on the basis of similar types of features.
- example- it suggests the items bought together if people buy coke our machine will suggest other items with similar items as coke
3-> Hybrid recommendation
- Collaborative + Content based RS
1.2 Technologies for Recommendation system
We can implement a recommendation system with different technologies, some of them are
every technology or method have their pros and cons.
2. Market basket analysis
It explains the combination of products that frequently co-occur in transaction
It works on two parts:-
- Association rule mining
- Apriori Algorithm
2.1 Association Rule mining
It’s a technique that shows how items are associated with each other.
2.2 Apriori algorithm
The above relation is calculated from all the previous orders data we have
A relationship between two items is calculated by the Apriori algorithm.
for this, the algorithm calculates 3 main factors to establish the relationship
- Support: Fraction of transaction which contains item A and B
- Confidence: it gives how often the items A and B occur together, for a given number of total times A occurs
- lift: it indicates the strength of a rule over random co-occurrence of A and B
for lift, the formula is
Lift = main_Support / ( support(A) * support(B) )
lift is high = there is no relation between those two products
lift is low = there is a relation between those two products
Apriori algorithm will calculate all these factors for all of the distinct items and will return a query set of relations for this.
Now it’s up to you, you have the relationship between two products, how you want to implement the working.
Remember this
Apriori algorithm works with a sparse dataset, it's a statistical approach for recommendation method.
you have to train your data again to get the latest orders into the dataset.
In the next part, we will learn how to implement this algorithm for our own project.
I have used python with MongoDB.
Thanks for reading