Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.13.0
title: Business Intelligence Dashboard
emoji: π
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 6.0.2
app_file: app.py
pinned: false
Business Intelligence Dashboard
An interactive Business Intelligence dashboard built with Gradio that enables users to explore and analyze business data through an intuitive, Tableau-like web interface.
Features
π Data Upload & Validation
- Upload CSV or Excel files through the web interface
- Display basic dataset information (shape, columns, data types)
- Show data preview (first 10 rows)
- Graceful error handling with informative messages
π Data Exploration & Summary Statistics
- Automated Data Profiling:
- Numerical columns: mean, median, std, min, max, quartiles
- Categorical columns: unique values, value counts, mode
- Missing value report
- Correlation matrix for numerical features
π Interactive Filtering
- Dynamic filtering interface based on column types:
- Numerical: Range sliders with min/max inputs
- Categorical: Multi-select checkboxes
- Date: Date range pickers (when applicable)
- Real-time row count updates as filters are applied
- Display filtered data preview
π Visualizations
Implements 5 different visualization types:
- Time Series Plot: Trends over time with aggregation options
- Distribution Plot: Histogram or box plot for numerical data
- Category Analysis: Bar chart or pie chart for categorical data
- Scatter Plot: Show relationships between variables
- Correlation Heatmap: Visualize correlations between numerical features
Features:
- User selects which columns to visualize
- Clear titles, labels, and legends
- Multiple aggregation methods (sum, mean, count, median)
- Professional Plotly visualizations
π‘ Insights Generation
Automatically generates insights:
- Top/Bottom Performers: Identify highest/lowest values
- Basic Trends: Detect patterns in time series data
- Summary Statistics: High-level dataset overview
πΎ Export Functionality
- Export filtered data as CSV
- Export visualizations as PNG images
High-Level Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interface β
β (Gradio Web Interface) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Data Upload β β Visualizationβ β Insights β β
β β & Preview β β & Charts β β Generation β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Statistics β β Filter & β β Export β β
β β & Profiling β β Explore β β Functionalityβ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application Layer (app.py) β
β β’ Orchestrates user interactions β
β β’ Manages global state (current_df, filters, figures) β
β β’ Routes requests to appropriate modules β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β Data Processing β β Visualizations β β Insights β
β Layer β β Layer β β Layer β
β β β β β β
β data_processor.pyβ βvisualizations.py β β insights.py β
β β β β β β
β β’ CSV/Excel Load β β β’ Time Series β β β’ Top/Bottom β
β β’ Data Cleaning β β β’ Distribution β β Performers β
β β’ Filtering β β β’ Category β β β’ Trend Analysis β
β β’ Statistics β β Analysis β β β’ Summary Stats β
β Generation β β β’ Scatter Plot β β β
β β β β’ Correlation β β β
β β β Heatmap β β β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β β β
ββββββββββββββββββββββΌβββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Utilities Layer (utils.py) β
β β’ Column type detection (numerical, categorical, date) β
β β’ Missing value analysis β
β β’ Data validation helpers β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Data Sources β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β stocks.csv β βsales_train β βOnline Retail β β
β β β β .csv β β .xlsx β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
β β’ CSV files (pandas.read_csv) β
β β’ Excel files (pandas.read_excel) β
β β’ User-uploaded datasets β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β External Libraries β
β β’ pandas: Data manipulation and analysis β
β β’ plotly: Interactive visualizations β
β β’ gradio: Web interface framework β
β β’ numpy: Numerical computations β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Project Structure
project/
βββ app.py # Main Gradio application
βββ data_processor.py # Data loading, cleaning, filtering
βββ visualizations.py # Chart creation functions
βββ insights.py # Automated insight generation
βββ utils.py # Helper
βββ constants.py # Constants used throughout the code
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ data/ # Sample datasets
βββ sales_train.csv
βββ stocks.csv
βββ Online Retail.xlsx
Setup Instructions
1. Install Dependencies
pip install -r requirements.txt
Note: This project uses Gradio 6.0.2, which includes improved performance and updated APIs. Make sure you have Python 3.8 or higher installed.
2. Run the Application
python app.py
The application will launch and be accessible at http://localhost:7860 in your web browser.
Usage
- Upload Data: Navigate to the "Data Upload & Preview" tab and upload a CSV or Excel file
- View Statistics: Go to "Statistics & Profiling" to see comprehensive data statistics
- Apply Filters: Use "Filter & Explore" to filter your data by column values
- Create Visualizations: Visit "Visualizations" to create interactive charts
- Generate Insights: Check "Insights" for automated data insights
- Export Data: Use "Export" to download filtered data or visualizations
Aggregation Methods
The dashboard supports multiple aggregation methods for visualizations:
- Sum: Adds all values together (useful for totals, volumes)
- Mean: Calculates the average value (useful for prices, rates)
- Count: Counts the number of data points (useful for frequency)
- Median: Finds the middle value (robust to outliers)
- None: No aggregation (shows raw data points)
Step-by-Step Tutorial: Monthly Average Closing Price
Let's walk through a complete example:
Step 1: Load the Data
- Open the dashboard
- Go to π Data Upload & Preview tab
- Click Upload Dataset
- Select
sample-datasets/stocks.csv - Click Load Data
- Verify the data preview shows the stock data
Step 2: Create the Visualization
- Navigate to π Visualizations tab
- Configure the chart:
- Chart Type:
Time Series - X-Axis Column:
Date - Y-Axis Column:
Close - Aggregation Method:
Mean
- Chart Type:
- Click Generate Visualization
Step 3: Interpret the Results
- The chart shows a line graph with dates on X-axis and average closing prices on Y-axis
- Each point represents the mean closing price for that date
- You can see trends, patterns, and changes over time
Step 4: Compare Different Aggregations
Try generating the same chart with different aggregation methods:
- Mean: Average closing price (smooth trend)
- Sum: Total closing price (not meaningful for prices, but shows concept)
- Median: Middle closing price (robust to outliers)
- None: All individual closing prices (may be cluttered)
Technical Details
Design Patterns
The application uses the Strategy Pattern for:
- Data Loading: Different strategies for CSV vs Excel files
- Data Filtering: Different strategies for numerical, categorical, and date filters
- Visualizations: Different strategies for each chart type
Code Quality
- Follows PEP 8 style guidelines
- Comprehensive docstrings for all functions
- Proper error handling with try/except blocks
- Modular design with clear separation of concerns
- No hardcoded values (uses constants and configuration)
Libraries
- pandas 2.2.0+: All data manipulation and analysis
- Gradio 6.0.2: Web interface framework
- Plotly 5.22.0+: Interactive visualizations
- matplotlib 3.8.0+ / seaborn 0.13.0+: Additional visualization support
- Python 3.8+: Following best practices
Sample Datasets
The data/ folder includes sample datasets:
sales_train.csv: Sales transaction datastocks.csv: Stock market dataOnline Retail.xlsx: E-commerce retail data
Requirements
- Python 3.8 or higher
- All dependencies listed in
requirements.txt:- pandas >= 2.2.0
- numpy >= 1.26.0
- gradio == 6.0.2
- matplotlib >= 3.8.0
- seaborn >= 0.13.0
- plotly >= 5.22.0
- kaleido >= 0.2.1
- openpyxl >= 3.1.5
- Pillow >= 10.4.0
License
This project is created for educational purposes as part of CS5130 coursework.