File size: 2,833 Bytes
126bf67
cae1c9c
5fc7138
 
 
126bf67
5fc7138
126bf67
 
 
 
2130e8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: CausalAI
emoji: 🐨
colorFrom: blue
colorTo: yellow
sdk: gradio
sdk_version: 4.39.0
app_file: app.py
pinned: false
---

# Causal AI - Synthetic Customer Data Generator and RCT Simulator

## Project Overview

This project provides a comprehensive toolkit for generating synthetic e-commerce customer data, simulating Randomized Control Trials (RCTs), and analyzing the results using causal inference techniques. It's designed to help data scientists and analysts explore the impact of various discount strategies on customer behavior and business metrics.

## Key Features

1. **Synthetic Data Generation**: Create realistic customer profiles with various attributes.
2. **RCT Simulation**: Run experiments with different discount levels.
3. **Results Analysis**: Analyze the impact of discounts on key business metrics.
4. **Uplift Modeling**: Build and evaluate uplift models to predict individual treatment effects.
5. **Targeted Policy Simulation**: Test targeting strategies based on uplift model predictions.

## Project Structure

- `app.py`: Main application file with Gradio interface
- `data_generator.py`: Synthetic customer data generation
- `rct_simulator.py`: Randomized Control Trial simulation
- `rct_analyzer.py`: Analysis of RCT results
- `requirements.txt`: List of required Python packages

## Installation

1. Clone the repository:
   ```
   git clone https://github.com/neurons-lab/causal-ai.git
   cd causal-ai
   ```

2. Create a virtual environment (optional but recommended):
   ```
   python -m venv venv
   source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
   ```

3. Install the required packages:
   ```
   pip install -r requirements.txt
   ```

## Usage

Run the main application:

```
python app.py
```

This will start the Gradio interface, which you can access through your web browser. The interface is divided into several tabs:

1. **Generate Customer Data**: Create synthetic customer profiles.
2. **Run RCT Simulation**: Simulate a Randomized Control Trial with different discount levels.
3. **Analyze RCT Results**: View and analyze the results of the RCT.
4. **Exploratory Data Analysis**: Explore the impact of discounts on different customer segments.
5. **Build Uplift Model**: Create uplift models to predict individual treatment effects.
6. **Run Targeting Policy**: Test targeting strategies based on uplift model predictions.

## Customization

You can customize various aspects of the simulation:

- Modify the `electronics_products` list in `rct_simulator.py` to change the available products.
- Adjust the `calculate_purchase_probability` function in `rct_simulator.py` to alter how customer attributes affect purchase likelihood.
- Update the `REGIONS` dictionary in `data_generator.py` to change the demographic characteristics of different regions.