Spaces:
Configuration error
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
- ๐ API Key Setup - Secure Groq API integration
- ๐ Variable Extraction - AI-powered variable identification
- ๐ Questionnaire Generator - Dynamic survey creation
- ๐ข Data Generation - Realistic sample data creation
- ๐งน Data Cleaning - Comprehensive preprocessing
- ๐ EDA Module - Statistical analysis with AI insights
- ๐ค Predictive Analytics - Machine learning simulation
- ๐ Trend Analysis - Time series analysis and forecasting
- ๐ญ Sentiment Analysis - Customer feedback analysis
- ๐งช A/B Testing - Statistical significance testing
- ๐ฌ Chat with Data - Interactive AI-powered Q&A
- ๐ค 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
๐ Set API Key
- Enter your Groq API key for AI features
- Skip this step to use fallback functionality
๐ Extract Variables
- Describe your business problem
- AI extracts relevant marketing variables
- Review and proceed to next step
๐ Generate Questionnaire
- Automatically creates survey questions
- Based on extracted variables
- Mix of multiple choice and descriptive questions
๐ข Generate Sample Data
- Creates realistic sample dataset
- Configurable sample size (100-10,000 records)
- Based on your specific variables
๐งน Clean Data
- Handles missing values and outliers
- Removes duplicates
- Provides cleaning statistics
๐ Perform EDA
- Statistical analysis and correlations
- AI-generated insights
- Distribution analysis
๐ค Train Predictive Model
- Multiple algorithm options
- Performance metrics simulation
- Feature importance analysis
๐ Analyze Trends
- Time series analysis
- Seasonality detection
- Revenue forecasting
๐ญ Analyze Sentiment
- Customer feedback analysis
- Sentiment distribution
- Actionable recommendations
๐งช Run A/B Test
- Statistical significance testing
- Conversion rate analysis
- Winner determination
๐ฌ Chat with Data
- Interactive Q&A about your analysis
- AI-powered insights
- Context-aware responses
๐ค 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
- Input โ Business problem description
- Processing โ AI variable extraction
- Generation โ Sample data creation
- Cleaning โ Data preprocessing
- Analysis โ Statistical insights
- Modeling โ Predictive analytics
- Visualization โ Trend and sentiment analysis
- Testing โ A/B test evaluation
- Interaction โ Chat-based exploration
- 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)"