comfyCausalAI / README.md
rknl's picture
fixes plot
cae1c9c verified

A newer version of the Gradio SDK is available: 5.44.0

Upgrade
metadata
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.