BI_ANALYTICS / README.md
ratulsur's picture
Upload 8 files
e51a81b verified

BI Storyteller - Python Standard Library Edition

A comprehensive marketing analysis automation platform built entirely with Python's standard library, designed to work in WebContainer environments.

๐ŸŽฏ Features

Complete 12-Module Workflow

  1. ๐Ÿ”‘ API Key Setup - Secure Groq API integration
  2. ๐Ÿ“ Variable Extraction - AI-powered variable identification
  3. ๐Ÿ“‹ Questionnaire Generator - Dynamic survey creation
  4. ๐Ÿ”ข Data Generation - Realistic sample data creation
  5. ๐Ÿงน Data Cleaning - Comprehensive preprocessing
  6. ๐Ÿ“Š EDA Module - Statistical analysis with AI insights
  7. ๐Ÿค– Predictive Analytics - Machine learning simulation
  8. ๐Ÿ“ˆ Trend Analysis - Time series analysis and forecasting
  9. ๐Ÿ’ญ Sentiment Analysis - Customer feedback analysis
  10. ๐Ÿงช A/B Testing - Statistical significance testing
  11. ๐Ÿ’ฌ Chat with Data - Interactive AI-powered Q&A
  12. ๐Ÿ“ค Export & Import - Data persistence and sharing

Key Capabilities

  • ๐ŸŒ Web Interface - Professional browser-based UI
  • ๐Ÿ’ป CLI Interface - Command-line interaction option
  • ๐Ÿค– AI Integration - Groq LLM for intelligent insights
  • ๐Ÿ“Š Statistical Analysis - Comprehensive data analysis
  • ๐Ÿ”„ Workflow Management - Sequential module progression
  • ๐Ÿ’พ Data Persistence - CSV and JSON export/import
  • ๐ŸŽจ Professional UI - Clean, modern web interface

๐Ÿš€ Quick Start

Option 1: Web Interface (Recommended)

python main.py

Then open your browser to http://localhost:8000

Option 2: Command Line Interface

python cli_interface.py

๐Ÿ“‹ Requirements

Environment: Python 3.6+ (Standard Library Only)

  • No external dependencies required
  • Works in WebContainer, local environments, and cloud platforms
  • Compatible with restricted Python environments

Optional: Groq API key for AI-powered features

  • Get free API key at console.groq.com
  • Fallback functionality available without API key

๐ŸŽฎ Usage Guide

Web Interface Workflow

  1. ๐Ÿ”‘ Set API Key

    • Enter your Groq API key for AI features
    • Skip this step to use fallback functionality
  2. ๐Ÿ“ Extract Variables

    • Describe your business problem
    • AI extracts relevant marketing variables
    • Review and proceed to next step
  3. ๐Ÿ“‹ Generate Questionnaire

    • Automatically creates survey questions
    • Based on extracted variables
    • Mix of multiple choice and descriptive questions
  4. ๐Ÿ”ข Generate Sample Data

    • Creates realistic sample dataset
    • Configurable sample size (100-10,000 records)
    • Based on your specific variables
  5. ๐Ÿงน Clean Data

    • Handles missing values and outliers
    • Removes duplicates
    • Provides cleaning statistics
  6. ๐Ÿ“Š Perform EDA

    • Statistical analysis and correlations
    • AI-generated insights
    • Distribution analysis
  7. ๐Ÿค– Train Predictive Model

    • Multiple algorithm options
    • Performance metrics simulation
    • Feature importance analysis
  8. ๐Ÿ“ˆ Analyze Trends

    • Time series analysis
    • Seasonality detection
    • Revenue forecasting
  9. ๐Ÿ’ญ Analyze Sentiment

    • Customer feedback analysis
    • Sentiment distribution
    • Actionable recommendations
  10. ๐Ÿงช Run A/B Test

    • Statistical significance testing
    • Conversion rate analysis
    • Winner determination
  11. ๐Ÿ’ฌ Chat with Data

    • Interactive Q&A about your analysis
    • AI-powered insights
    • Context-aware responses
  12. ๐Ÿ“ค Export Results

    • Download complete analysis as JSON
    • Save data as CSV files
    • Share results with stakeholders

Command Line Interface

The CLI provides the same functionality through an interactive menu system:

python cli_interface.py

Navigate through numbered options (1-15) to complete your analysis workflow.

๐Ÿ”ง Technical Architecture

Core Components

main.py - Core BIStoryteller class with all analysis methods

  • Variable extraction with AI integration
  • Data generation and cleaning algorithms
  • Statistical analysis and correlation calculations
  • Predictive modeling simulation
  • Trend analysis and forecasting
  • Sentiment analysis with rule-based fallbacks
  • A/B testing with statistical significance
  • Chat interface with contextual responses

web_interface.py - HTTP server with REST API

  • Professional HTML/CSS/JavaScript interface
  • RESTful API endpoints for all modules
  • Real-time status updates
  • Responsive design for all devices

cli_interface.py - Command-line interface

  • Interactive menu system
  • Formatted output displays
  • Progress tracking
  • User-friendly prompts

Data Flow

  1. Input โ†’ Business problem description
  2. Processing โ†’ AI variable extraction
  3. Generation โ†’ Sample data creation
  4. Cleaning โ†’ Data preprocessing
  5. Analysis โ†’ Statistical insights
  6. Modeling โ†’ Predictive analytics
  7. Visualization โ†’ Trend and sentiment analysis
  8. Testing โ†’ A/B test evaluation
  9. Interaction โ†’ Chat-based exploration
  10. Export โ†’ Results and data export

๐ŸŒŸ Key Features

AI-Powered Analysis

  • Groq LLM Integration for intelligent variable extraction
  • Contextual Questionnaire Generation based on business problems
  • Smart Insights Generation from statistical analysis
  • Interactive Chat with your data and results

Statistical Capabilities

  • Correlation Analysis with Pearson coefficients
  • Distribution Analysis with descriptive statistics
  • Trend Detection with significance testing
  • A/B Testing with proper statistical methods
  • Forecasting with confidence intervals

Professional Interface

  • Modern Web UI with responsive design
  • Real-time Updates and progress indicators
  • Error Handling with user-friendly messages
  • Data Visualization through statistical summaries
  • Export Capabilities for sharing and persistence

Robust Architecture

  • Modular Design with clear separation of concerns
  • Error Handling with graceful fallbacks
  • Data Validation at every step
  • Memory Efficient processing
  • Cross-platform compatibility

๐Ÿ“Š Sample Workflow

# Initialize BI Storyteller
bi = BIStoryteller()

# Set API key
bi.set_groq_api_key("your_groq_api_key")

# Extract variables
variables = bi.extract_variables("We want to improve customer retention and increase purchase frequency")

# Generate questionnaire
questionnaire = bi.generate_questionnaire(variables, business_problem)

# Generate and clean data
sample_data = bi.generate_sample_data(variables, 1000)
cleaned_data, cleaning_results = bi.clean_data(sample_data)

# Perform analysis
eda_results = bi.perform_eda(cleaned_data)
model_results = bi.train_predictive_model(cleaned_data, "Random Forest")
trend_results = bi.analyze_trends(cleaned_data, "Monthly")

# Interactive analysis
response = bi.chat_with_data("What are the key factors driving customer satisfaction?")

# Export results
bi.export_results("my_analysis.json")

๐Ÿ› ๏ธ Customization

Adding New Analysis Methods

Extend the BIStoryteller class with new methods:

def custom_analysis(self, data, parameters):
    """Add your custom analysis logic"""
    # Your analysis code here
    return results

Modifying the Web Interface

Edit the HTML template in web_interface.py to customize:

  • UI styling and layout
  • Form fields and options
  • Result display formats
  • Additional functionality

Extending API Endpoints

Add new endpoints in the do_POST method:

elif self.path == '/api/custom_endpoint':
    # Handle custom functionality
    result = self.bi.custom_analysis(data)
    self._send_json_response({'results': result})

๐Ÿ”’ Security & Privacy

  • API keys stored in memory only (not persisted)
  • No external data transmission except to Groq API
  • Local data processing - your data stays on your machine
  • No tracking or analytics - completely private

๐Ÿš€ Deployment Options

Local Development

python main.py  # Web interface on localhost:8000
python cli_interface.py  # Command line interface

Cloud Deployment

The application can be deployed to any Python-supporting platform:

  • Heroku, Railway, Render
  • Google Cloud Run, AWS Lambda
  • Any VPS with Python support

Docker Deployment

FROM python:3.9-slim
COPY . /app
WORKDIR /app
EXPOSE 8000
CMD ["python", "main.py"]

๐ŸŽฏ Use Cases

Marketing Teams

  • Customer segmentation analysis
  • Campaign performance optimization
  • A/B testing for marketing materials
  • Customer satisfaction tracking

Data Analysts

  • Automated EDA workflows
  • Predictive modeling pipelines
  • Trend analysis and forecasting
  • Statistical significance testing

Business Consultants

  • Client data analysis automation
  • Professional reporting generation
  • Interactive data exploration
  • Stakeholder presentation preparation

Research Teams

  • Survey design and analysis
  • Statistical hypothesis testing
  • Data cleaning and preprocessing
  • Collaborative analysis workflows

๐Ÿค Support

Getting Help

  • Check error messages in terminal/browser console
  • Review the workflow sequence (modules must be completed in order)
  • Verify API key is set correctly for AI features

Troubleshooting

  • Port already in use: Change port in start_web_server(port=8001)
  • API errors: Check Groq API key validity and internet connection
  • Data issues: Ensure previous modules are completed before proceeding

Feature Requests

The application is designed to be comprehensive and extensible. You can:

  • Add custom analysis methods to the core class
  • Extend the web interface with new modules
  • Integrate additional AI providers
  • Customize the statistical analysis methods

๐Ÿ“„ License

This project is provided as-is for educational and commercial use.


๐Ÿš€ Ready to automate your marketing analysis? Start with the web interface or CLI and transform your business problems into actionable insights!

Quick Commands:

# Start web interface
python main.py

# Start CLI interface  
python cli_interface.py

# View this help
python -c "import main; help(main.BIStoryteller)"