Market basket analysis is a well-known problem in data mining that can help businesses better understand customer behavior and optimize their operations.

Recently, machine learning and neural networks have emerged as powerful tools for solving this problem.

Here, we explore how these techniques can be used to perform market basket analysis and provide examples of their practical applications in the retail industry.

Contents

  1. Introduction.
  2. Application type.
  3. Data set.
  4. Neural network.
  5. Model deployment.

We use the data science and machine learning platform Neural Designer to solve this example. To follow it step by step, you can use the free trial.

Introduction

In this blog post, we’ll explore how businesses can identify which products are commonly purchased together by analyzing transactional data and leverage this insight to enhance product recommendations, marketing strategies, and store layout.

Machine learning algorithms have made market basket analysis more accessible than ever, allowing retailers to extract valuable insights from large datasets in real-time.

In this example, we’ll see how neural networks are a powerful tool that can be used to discover latent patterns in transactional data and generate meaningful rules that allow us to create practical applications of market basket analysis in the retail industry.

Application type

In this application type, the number of outputs is the same as the number of inputs. Therefore, this is an auto-association problem.

Auto association, specifically in the context of market basket analysis, refers to a technique used to identify patterns in customer purchase behavior by analyzing the co-occurrence of items in transactions.

The idea behind the auto association is to build a model from the associations between different items that tend to be purchased together, then use this knowledge to make recommendations or optimize product placement in a store. This is the primary goal of this example.

Data set

The first step is to prepare the data set, which is the source of information for this auto association problem.
It is composed of:

Data source

The dataset selected for our example consists of 9835 grocery store transactions. Each transaction can be a single product or several products.

The file Shopping_Cart.csv contains the data set after being submitted for processing.

Statistics

Once the data has been processed, it is time to add it to Neural Designer to create our recommendation system.
Neural Designer provides an easy way of analyzing and deploying advanced analytics models.

We can check the basic statistics of each variable, which gives us valuable information when designing a model and also offers significant insights into our application.

The table below shows the minimums, maximums, means, and standard deviations of the 20 most frequent variables in this data set.

Statistics of Basket market analysis

Neural network

We use neural networks to develop our recommendation system, the machine learning technique that Neural Designer implements. The neural network defines the predictive model as a multidimensional function containing adjustable parameters.
The first step to creating our recommendation system is choosing a neural network architecture representing the classification function.

The neural network of this problem is very complex (169 inputs, 25 hidden neurons, and 169 outputs). The following image represents the Neural Designer interface where the number of neurons in the perceptron layers can be chosen.


The next step is to train the neural network mentioned above. For this purpose, we apply the Adaptive Moment Estimation method to obtain a good model to recommend a shopping basket more suitable for the customer.

The resulting training error using the adaptive moment estimation method is 0.674. We are ready to deploy our model to recommend products to customers based on their purchasing history.

Model deployment

We can analyze an example of a customer’s shopping cart to check, for example, what recommendations our system would make.

The following items make up a customer’s shopping basket:

  • citrus fruit
  • frozen meat
  • newspaper
  • other vegetables
  • whole milk

Applying our model to that customer, the recommended products are the following:

  • Instant food products
  • yogurt
  • buttermilk
  • frozen fish
  • red/blush wine
  • pip fruit
  • butter

Recommendation of shopping basket

Conclusions

Market basket analysis (MBA) uses machine learning and neural networks to identify relationships between customer purchases.

They have various applications in MBA, including product recommendation, sales forecasting, customer segmentation, fraud detection, and pricing optimization.

Overall, machine learning and neural networks have numerous applications in MBA, and their ability to analyze large datasets and identify complex patterns makes them valuable tools for businesses looking to optimize their operations and improve their bottom line.

Related posts