Steve Jobs once said, “customers don’t know what they want until you show it to them.” Now, personalized recommendations exist anywhere from e-commerce (Amazon) to entertainment ( Netflix, YouTube, and Spotify). Their recommendation systems are key in driving revenue and making them successful companies. Even Amazon increased its revenue by 35% from their recommendation system and email campaigns.

E-commerce retailers can easily access data about their customers, products, and order/purchase history. With this data, retailers can make targeted recommendations to their customers to cross sell or up-sell products.

**What is cross selling and up-selling?**

Cross selling recommends customers to buy related or complementary items. For example, if a customer purchases a computer keyboard, then cross selling would recommend a complementary item such as a mouse.

Up-selling recommends customers to purchase a higher priced item or add-on to the product they’re interested in. For example, if a customer is originally interested in a 13-inch $500 laptop an up-sell would be to recommend a 15-inch $1,000 laptop that is larger and has better hardware.

Cross selling and up-selling is important because it increases revenue and produces a more personalized shopping experience. According to Forrester Research, cross selling and up-selling is responsible for an average of 10-30% of e-commerce business revenues.

Customers are also more likely to shop and return to sites that offer personalized recommendations and acquiring a new customer is 5 – 25 times more expensive than keeping a current one. Therefore, product recommendations are an important way to keep current customers engaged. Market Basket Analysis and Collaborative Filtering are important ways to cross-sell and upsell products to customers.

### Market Basket Analysis(MBA):

Market basket analysis is used to identify which products/itemsets are “frequently bought together”. For example, if a customer has a camera in their shopping cart, MBA will show that memory cards are also frequently purchased with cameras. Kurvv will help suggest products like a memory card to customers who may not have thought to purchase it otherwise. (this algorithm is coming soon)

#### What is Market Basket Analysis doing?

Market Basket Analysis (Association Rules) is performed to find relationships between sets of elements of distinct transactions. These indicate which products are “frequently bought together”. The mlxtend package in Python is used. MBA takes in an order-item matrix, where the rows are unique orders (OrderID), the columns are items, and the values are binary values of whether the item was purchased in the order (1) or not (0). The goal is to find out what items customers frequently purchase together and generate a set of Association Rules to uncover associations between items. The apriori algorithm identifies frequent itemsets (group of one or more items) above a minimum support or confidence threshold (value set by user).

Support is the default popularity of an item, which mathematically is the ratio of transactions involving that item to the total number of transactions.

Support(A) = (Transactions involving A)/(Total transactions)

Confidence is the strength of an association rule or how often it’s been found to be true. Given A, how often do we see B. It divides the number of transactions involving both A and B by the number of transactions involving A.

Confidence(A => B) = support(A U B)/support(A)

Next, market basket analysis filters out rules that do not meet the threshold for lift, which is some value greater than 1.

Lift factors in the expected probability of co-occurrence based only on chance to see if events are truly independent from each other. It’s the ratio of the observed support to that expected if A and B were independent.

Lift(A => B) = Confidence(A, B) / Support(B) = Support(A U B) / Support(A) x Support (B)

**1.** Lift (A => B) > 1 indicates positive correlation with the products in the itemset. A and B are more likely to be bought together. Co-occurrence is more likely than chance.

**2.** Lift (A => B) < 1 indicates negative correlation with the products in the itemset. A and B are unlikely to be bought together.

**3.** Lift (A => B) = 1 means there is no correlation.

MBA produces a set of rules, where every rule is composed of two different itemsets A and B where A is the antecedent (Left Hand Side – LHS) and B is the consequent (Right Hand Side – RHS). A => B means that if A is bought, customers also buy B and these items are frequently bought together. For example, suppose a population has an average response rate of 5%, but a certain rule has identified a segment with a response rate of 20%. Then that segment would have a lift of 4.0 (20%/5%). MBA is important in identifying complementary items and substitute items and showing products that customers tend to buy together. This improves cross-selling opportunities.

### User-based Collaborative Filtering:

Product recommendations are based on other customers who have purchased similar products. Collaboration comes from matching users’ preferences/confidence to people with similar tastes. Filtering is making predictions of a user’s interests/similarities by collecting preferences from other users similar to their own preferences.

There are a few assumptions made in collaborative filtering:

**1.** Customers who agreed in the past will agree in the future

**2.** Customers like similar kinds of items they liked in the past.

The general idea is that if A purchases a similar product to B, then A is more likely to purchase an item B has purchased compared to a random person. Each user has their own unique predictions derived from information from many other users.

Collaborative filtering requires users to be active customers. If customers only purchase one distinct item it may be difficult to recommend other products. There is also a “cold start” problem, which occurs when new customers or items arrive and there’s no purchase data for them. In this case, we can recommend popular items. Popular items are also recommended and can be used as a baseline to evaluate the usefulness of collaborative filtering recommendations. With collaborative filtering, Kurvv can help increase sales by recommending products customers are likely to purchase. (currently available for use)

### What is Collaborative filtering doing?

The Alternating Least Squares (ALS) algorithm is a popular model for collaborative filtering with implicit data and is implemented using the Implicit package in Python. The Alternating Least Squares algorithm takes in a user-item matrix where the rows are users that liked that item, the columns are items, and the value is the confidence that the user liked the item (quantity purchased in this case). ALS starts with a matrix R (m x n), the user-item sparse matrix, which is factored into smaller matrices X (m x k) and Y (k x n), where k = the number of latent factors, X = latent user feature vectors for each user, and Y = latent item feature vectors for each item. ALS first fills in X and Y with random numbers, calculates a cost function, and iterates between X and Y to reduce the cost function until a global minimum can be computed. The goal is to find a vector x_{u} for each user u, and a vector y_{i} for each item i that will factor user preferences. Preferences are assumed to be the inner products: p_{ui} = x_{u}^{T}y_{i}

Once X and Y are multiplied back together, the empty values in matrix X and Y are filled in and they produce an approximation of the original matrix R. These filled in values are the recommendations that are made. Thus, we are able to find a vector x_{u} for each user u, and a vector y_{i} for each item i that will factor user preferences. Preferences are assumed to be the inner products: p_{ui} = x_{u}^{T}y_{i}. These recommendations from ALS can be used to up-sell and cross-sell products.

The hyperparameters that need to be tuned for the ALS algorithm are:

**1. Alpha value**

• Rate of increase, constant α, in confidence as we observe more evidence for positive preference.

• Used to calculate the confidence matrix c_{ui} = 1+r_{ui}

**2. Latent Factors**

• Number of latent factors to compute

**3. Regularization Factor**

• Regularization parameter so that it won’t overfit the training data.

**4. Iterations**

• Maximum number of iterations to run

• Usually at least 10 times to convergence

Kurvv can help retailers identify which products are frequently purchased together (Market Basket Analysis) and make recommendations to customers for products (Collaborative Filtering) to cross sell and up-sell products and generate more revenue for your company.Please stay tuned for announcement for availability of each algorithm.