Skip to content

Python modules to check effectiveness of multi-armed bandit for generating recommendations

Notifications You must be signed in to change notification settings

70Shubham07/recommendation_system_lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Here’s a concise and informative README.md for your script:


πŸ§ͺ Multi-Armed Bandit Simulation for Product Recommendation Algorithms

This project simulates user interactions with product recommendation algorithms using multi-armed bandit strategiesβ€”Thompson Sampling, Upper Confidence Bound (UCB), and Random Selectionβ€”to evaluate which algorithm drives more user engagement (clicks).

πŸ“Œ Purpose

The goal is to simulate and analyze how different recommendation algorithms perform in driving user selections from various product divisions. It seeks to answer:

  • Does the algorithm type affect user decisions?
  • Is there a statistically significant difference in engagement between algorithms?

πŸ—οΈ Architecture Overview

The simulation comprises the following stages:

1. Data Initialization

  • Reads product data from Items_without_duplicates.csv.
  • Extracts product divisions (categories).
  • Creates a list of User objects from a user_data class, initializing internal tracking for each algorithm.

2. Trial Simulations

For each algorithm:

  • Runs multiple trials for each user.
  • In each trial:
    • Recommends a division based on the algorithm.
    • Uses bias-based acceptance to simulate user behavior.
    • Updates internal tracking stats (clicks, impressions).

3. Statistical Evaluation

  • Performs a Chi-Squared Test to assess if user engagement varies by algorithm.
  • Conducts a T-Test to determine if there's a statistically significant difference in click rates between UCB and Thompson Sampling.

πŸ“Š Output

  • Total clicks generated by each algorithm.
  • True/False indicating whether the algorithm type significantly impacts user behavior.
  • True/False indicating whether there's a significant difference between Thompson and UCB.

πŸ”§ Key Components

  • initialize_user_collection(...): Initializes users for each algorithm group.
  • generate_interaction_data_from_multiple_runs(...): Simulates user trials and updates user state.
  • check_if_algorithm_type_affects_user_decisions(...): Chi-squared test for independence.
  • check_for_significant_difference_between_clicks_due_to_algo_type(...): T-test for difference of means.

πŸ“ Dependencies

Make sure to have the following:

  • Items_without_duplicates.csv (Product data with at least dept_name and prod_name columns)
  • user_data class implementation
  • Utility functions in utils.py:
    • recommendation_by_thompson
    • recommendation_by_ucb
    • recommendation_by_random
    • get_division_probabilities
    • chi_squared_test_for_independence
    • t_test_for_difference_of_means

About

Python modules to check effectiveness of multi-armed bandit for generating recommendations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages