Skip to main content
HomePython

Course

Market Basket Analysis in Python

IntermediateSkill Level
4.8+
222 reviews
Updated 01/2026
Explore association rules in market basket analysis with Python by bookstore data and creating movie recommendations.
Start Course for Free
PythonMachine Learning4 hr15 videos52 Exercises4,350 XP14,523Statement of Accomplishment

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Loved by learners at thousands of companies

Group

Training 2 or more people?

Try DataCamp for Business

Course Description

What do Amazon product recommendations and Netflix movie suggestions have in common? They both rely on Market Basket Analysis, which is a powerful tool for translating vast amounts of customer transaction and viewing data into simple rules for product promotion and recommendation. In this course, you’ll learn how to perform Market Basket Analysis using the Apriori algorithm, standard and custom metrics, association rules, aggregation and pruning, and visualization. You’ll then reinforce your new skills through interactive exercises, building recommendations for a small grocery store, a library, an e-book seller, a novelty gift retailer, and a movie streaming service. In the process, you’ll uncover hidden insights to improve recommendations for customers.

Prerequisites

Data Manipulation with pandas
1

Introduction to Market Basket Analysis

In this chapter, you’ll learn the basics of Market Basket Analysis: association rules, metrics, and pruning. You’ll then apply these concepts to help a small grocery store improve its promotional and product placement efforts.
Start Chapter
2

Association Rules

Association rules tell us that two or more items are related. Metrics allow us to quantify the usefulness of those relationships. In this chapter, you’ll apply six metrics to evaluate association rules: supply, confidence, lift, conviction, leverage, and Zhang's metric. You’ll then use association rules and metrics to assist a library and an e-book seller.
Start Chapter
3

Aggregation and Pruning

The fundamental problem of Market Basket Analysis is determining how to translate vast amounts of customer decisions into a small number of useful rules. This process typically starts with the application of the Apriori algorithm and involves the use of additional strategies, such as pruning and aggregation. In this chapter, you’ll learn how to use these methods and will ultimately apply them in exercises where you assist a retailer in selecting a physical store layout and performing product cross-promotions.
Start Chapter
4

Visualizing Rules

In this final chapter, you’ll learn how visualizations are used to guide the pruning process and summarize final results, which will typically take the form of itemsets or rules. You’ll master the three most useful visualizations -- heatmaps, scatterplots, and parallel coordinates plots – and will apply them to assist a movie streaming service.
Start Chapter
Market Basket Analysis in Python
Course
Complete

Earn Statement of Accomplishment

Add this credential to your LinkedIn profile, resume, or CV
Share it on social media and in your performance review
Enroll Now

Don’t just take our word for it

*4.8
from 222 reviews
89%
11%
0%
0%
0%
  • Chengjin
    8 hours ago

  • Deepak
    2 days ago

    Good excercise

  • David
    last week

    This is one of the best courses I have completed in DataCamp. The instructor was GREAT!

  • Napaporn
    2 weeks ago

  • Vinmay
    2 weeks ago

  • Aastha Sanketbhai
    2 weeks ago

Chengjin

"Good excercise"

Deepak

"This is one of the best courses I have completed in DataCamp. The instructor was GREAT!"

David

FAQs

What is the Apriori algorithm and will I learn to apply it?

The Apriori algorithm identifies frequently co-purchased items in transaction data. You learn to apply it along with pruning and aggregation strategies to generate actionable product rules.

What kinds of recommendation scenarios are covered in the exercises?

You build recommendations for a grocery store, a library, an e-book seller, a novelty gift retailer, and a movie streaming service, giving you practice across diverse retail contexts.

Which metrics does the course use to evaluate association rules?

You apply six metrics: support, confidence, lift, conviction, leverage, and Zhang's metric. Each helps you quantify how meaningful a relationship between purchased items really is.

What visualization techniques are taught for presenting results?

Chapter 4 covers heatmaps, scatterplots, and parallel coordinates plots for summarizing rules and guiding the pruning process when narrowing down useful item associations.

What Python skills do I need before starting?

You need Intermediate Python and Data Manipulation with pandas. The course uses these skills to process transaction data and implement market basket analysis techniques.

Join over 19 million learners and start Market Basket Analysis in Python today!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Grow your data skills with DataCamp for Mobile

Make progress on the go with our mobile courses and daily 5-minute coding challenges.