Skip to content

Markov Chain Analysis on Customer Behavior in a (Fictional) Supermarket

License

Notifications You must be signed in to change notification settings

AlphanAksoyoglu/supermarket_markov_simulation

Repository files navigation

Markov Analysis on Customer Behavior in a (Fictional) Supermarket

Overview

A fictional supermarket has collected time/location data for their customers regarding which isles they visit (and checkout) with a resolution of 1min. A Markov-Chain, describing customer behavior, is extracted from this data and customer behavior is simulated, along with a visual simulation

Supermarket-Simulation

Tech Stack

  • Python 3.8 (See requirements.txt for libraries)

Data

/market_data Contains fictional supermarket data, describes position of the customer at an isle, or checkout, resolution 1 min. Entry is implied 1 min before the visit of the first isle

/generated_matrices Contains transition probability matrices generated by transition_probability_generator.py

/sim_ Simulations generated using the transition probability matrices by means of by means of a Monte Carlo Markov Chain Simulation by the SuperMarket class

Markov Process (A very brief description)

Discrete Markov Chains describe a memoryless transition process between well defined discrete states. Memoryless, means that the transition probability from state to state depends only on the current state .

Given observations of a system that transitions from a total number of states, is calculated simply as the total number of transitions observed from state to state , divided by total number of transitions from state (including )

Markov State Diagram Depicting Transition Probabilities

Markov State Diagram

Usage

Current Workflow is:

Data Transition Matrices Simulation Visualization.

All modules and scripts are functional, but user options are limited and requires editing the code to select different data and simulation parameters. These will be addressed in future updates.

Modules & Scripts

./calculation_library.py: Contains the SuperMarket(), and Customer() class and helper functions to calculate transition probability matrices from raw data, and simulate customer behaviour from these matrices.

./supermarket_visualization/visualization_library.py: Contains Customer() class, and helper functions to visualize the generated simulation

./supermarket_visualization/visualization_constants.py: Constains constants used in simulation in a VC() class

./supermarket_class_demo: Demostrates making a customer behaviour simulation

./transition_probability_generator.py: Calculates transtition probabilities

./visualize.py: Visualizes the simulation

./make_markov_state_diagram.py: Creates the Markov State Diagram shown on this README

Future Updates (Considered)

  • pd.concat() in a loop slows down the SuperMarket() class, will be addressed

  • Addressing the Constraint:

    • SuperMarket() class currently simulates customer behaviour with the constraint of , needs to be updated.

    • Visulization parameters are set w.r.t the constraint . These need to be generalized

  • Most file choice parameters, and options are built-in. These need to be moved to sysarg or as class/function parameters

Contributors

Licenses:

I personally thank the following content creators for making their creations available under the Creative Commons CC-BY-SA 3.0 License


Resource: Dungeon Floor

Creator: Clint Bellanger (pfunked deviantart)

Website: https://www.deviantart.com/pfunked/art/Stone-Dungeon-Floor-122524193

License: https://creativecommons.org/licenses/by-sa/3.0/


Resource: Supermarket Atlas

Creator: Sunisa Thondaengdee

Website: https://opengameart.org/content/supermarket-0

License: https://creativecommons.org/licenses/by-sa/3.0/


Resource: Bricks

Creator: Unknown

Website: http://pixeljoint.com/forum/forum_posts.asp?TID=19369

License: None

About

Markov Chain Analysis on Customer Behavior in a (Fictional) Supermarket

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •