Search⌘ K
AI Features

Feature #6: Products Frequently Viewed Together

Explore how to detect products frequently viewed together by analyzing user browsing sequences with sliding window and hash map algorithms. Understand how to efficiently find product groupings to enhance recommendation systems like Amazon's.

Description

We want to improve the recommendation system of products at Amazon. For this purpose, the management has decided that if a group of products is searched or viewed back to back by users, these products are similar or related. So, if another user is browsing one of these products, we can recommend the other ones to them. To determine these similar products, we will look at the previous activities of all users and check if particular products are viewed back to back.

Your task is to create a module that is given a dataset of product IDs in the order they were viewed by the user. You will also be given a list of products that are likely similar. Your job is to find how many times these products occur together in the dataset. The order of their occurrence does not matter unless they are back to back without any other products in between.

For example, let’s say the dataset of product IDs you are given is:[3, 2, 1, 5, 2, 1, 2, 1, 3, 4]. The candidates for similar products are [1, 2, 3]. We can see that these products occur together twice in the dataset, first at indices 0 to 2 and then at 6 to 8. The ...