Python Programming: Build a Recommendation Engine in Django

Python Programming: Build a Recommendation Engine in Django

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 43 lectures (9h 35m) | 5.47 GB

Collaborative Filtering with Python, Celery, Django, Worker Processes, Batch Predictions, SurpriseML, Keras, and more!

Build a recommendation engine using Django & a Machine Learning technique called Collaborative Filtering.

Users will rate movies and the system will automatically recommend new ones. These recommendations will be done in batches (ie not in real time) to unlock a more scalable system for training and helping thousands and thousands of users.

For this course, we’ll use a real dataset called MovieLens; this dataset is downloaded in CSV and is used on all kinds of machine learning tutorials. What’s special about this course is you’ll load this dataset into a SQL database through a Django model. This alone might be worth watching the course as SQL databases are far more powerful than CSV files.

To do the batch inference we implement the incredibly powerful background worker process called Celery. If you haven’t used Celery before, this will be an eye opening experience and when you couple it with Django you have a truly powerful worker process that can run tasks in the background, run tasks on a schedule, or a combination of both. Tasks in Celery are simply Python functions with a special decorator.

For rating movies, we’ll be using HTMX. HTMX is a way to dynamically update content *without* reloading the page at all. I am sure you know the experience whenever you click “like” or “subscribe” , that’s what HTMX gives us without the overhead of using 1 line of JavaScript. This course shows us a practical implementation of using HTMX not just for rating movies, but also sorting them, loading them, and doing much more.

The recommendation engine in Django is really a collection of 3 parts:

Web Process: Setup up Django to collect user’s interest and provide recommendations once available.

Machine Learning Pipeline: Extract data from Django, transform it, and train a Collaborative Filtering model.

Worker Process: This is the glue. We’ll use Celery to schedule/run the trained model predictions and update data for Django-related user recommendations.

What you’ll learn

  • Learn how to integrate Django & Celery
  • Learn how to use HTMX with Django for Dynamic Loading (no JavaScript Needed)
  • Training a Machine Learning Model with SurpriseML and an example in Keras
  • Build a rating system in Django with dynamic rating buttons. These ratings can be used on any Django Model
  • Learn how to run periodic background task and/or schedule functions to run exactly when needed
  • How to perform batch inference effectively using Django for *any* large workloads and/or ML packages
  • How to load large datasets into a SQL database through Django Models
  • Where to find great datasets online
  • How to implement an “infinite” review page that will always give a new item after rating.
  • So much more!
Table of Contents

Introduction
1 Welcome to Recommender
2 Requirements InDepth Walkthrough
3 Where to get help
4 Setup Project
5 Django as a ML Pipeline Orchestration Tool

Handling the Dataset
6 Generate Fake User Data
7 Django Management Command to add Fake User Data
8 Our Collaborative Filtering Dataset
9 Load The Movies Dataset into the Movie Django Model
10 Create Ratings Model with Generic Foreign Keys

Running Calculations with Django
11 Calculate Average Ratings
12 Generate Movie Ratings
13 Handling Duplicate Ratings with Signals
14 Calculate Movie Average Rating Task

Python Celery
15 Setup Celery for Offloading Tasks
16 Converting Functions into Celery Tasks

Django Views Auth
17 Movie List Detail View URLs and Templates
18 Django AllAuth
19 Update the Movie Ratings Task

User Ratings
20 Rendering Rating Choices
21 Display a Users Ratings

Dynamic Django with HTMX
22 Dynamic Requests with HTMX
23 Rate Movies Dynamically with HTMX
24 Infinite Rating Flow with Django HTMX
25 Rating Dataset Exports Model Task

Jupyter Notebooks with Django
26 Using Jupyter with Django
27 Load Real Ratings to Fake Users
28 Update Movie Data
29 Recommendations by Popularity

Machine Learning Collaborative Filtering
30 What is Collaborative Filtering
31 Collaborative Filtering with Surprise ML
32 Surprise ML Utils Celery Task For Surprise Model Training
33 Batch User Prediction Task

Handling Predictions in Django
34 Storing Predictions in our Suggestion Model
35 Updating Batch Predictions Based on Previous Suggestions
36 MLBased Movies Recommendations View
37 Trigger ML Predictions Per User Activity
38 Position Ranking for Movie Querysets
39 Movie Embedding Idx Field and Task
40 Movie Dataset Exports
41 Schedule for ML Training ML Inference Movie IDX Updates and Exports

Wrap Up
42 Overview of a Neural Network Colab Filtering Model
43 Thank you and next steps

Homepage