Spaces:
Sleeping
Sleeping
| title: ESG_Intelligence_Platform | |
| app_file: app.py | |
| sdk: gradio | |
| sdk_version: 6.0.2 | |
| # π ESG Intelligence Platform | |
| Advanced Multi-Label ESG Text Classification with Visual Analytics | |
|  | |
|  | |
|  | |
| ## β¨ Features | |
| ### π Single Text Analysis | |
| - **Real-time ESG classification** with confidence scores | |
| - **Visual radar chart** showing ESG profile | |
| - **Keyword highlighting** to explain predictions | |
| - **Interactive examples** for learning | |
| ### π Batch Processing | |
| - Upload **CSV or TXT files** for bulk analysis | |
| - **Aggregate statistics** and visualizations | |
| - **Export results** to CSV format | |
| - **Trend analysis** across documents | |
| ### π Visual Analytics | |
| - **ESG Radar Charts** - Visualize multi-dimensional ESG profiles | |
| - **Confidence Bars** - See per-category certainty | |
| - **Distribution Pie Charts** - Batch analysis summaries | |
| - **Score Trend Lines** - Track patterns across documents | |
| ## π Quick Start | |
| ### Installation | |
| ```bash | |
| # Clone or navigate to the app directory | |
| cd esg_app | |
| # Install dependencies | |
| pip install -r requirements.txt | |
| # Run the application | |
| python app.py | |
| ``` | |
| ### Access the App | |
| Once running, open your browser to: | |
| - Local: `http://localhost:7860` | |
| - Public (if share=True): Check terminal for URL | |
| ## π Usage Guide | |
| ### Single Text Analysis | |
| 1. **Enter text** in the input box (or select a sample) | |
| 2. Click **"π Analyze Text"** | |
| 3. View results: | |
| - **Prediction pills** showing detected categories | |
| - **ESG Radar** showing dimensional scores | |
| - **Confidence bars** with thresholds | |
| - **Highlighted keywords** explaining the classification | |
| ### Batch Analysis | |
| 1. **Upload a file**: | |
| - **CSV**: First column should contain text | |
| - **TXT**: Separate documents with blank lines | |
| 2. Click **"π Analyze Batch"** | |
| 3. View aggregate results and export to CSV | |
| ## π·οΈ ESG Categories | |
| | Category | Icon | Description | | |
| |----------|------|-------------| | |
| | **Environmental (E)** | πΏ | Climate, emissions, energy, waste, biodiversity | | |
| | **Social (S)** | π₯ | Labor practices, diversity, health & safety, community | | |
| | **Governance (G)** | βοΈ | Board structure, ethics, transparency, compliance | | |
| | **Non-ESG** | π | General business content without ESG relevance | | |
| ## π§ Model Architecture | |
| ``` | |
| Input Text | |
| β | |
| Qwen3-Embedding-8B (4096-dim) | |
| β | |
| StandardScaler | |
| β | |
| Logistic Regression Ensemble (per-class) | |
| β | |
| Threshold Optimization | |
| β | |
| Multi-Label Predictions | |
| ``` | |
| ### Key Technical Details | |
| - **Embedding Model**: Qwen3-Embedding-8B (4096 dimensions) | |
| - **Classification**: Logistic Regression with balanced class weights | |
| - **Cross-Validation**: 5-fold MultilabelStratifiedKFold | |
| - **Threshold Optimization**: Per-class + joint macro-F1 optimization | |
| - **Ensemble**: 3-seed averaging for robustness | |
| ## π Performance | |
| | Metric | Score | | |
| |--------|-------| | |
| | **Macro F1** | 0.82+ | | |
| | Environmental F1 | 0.78 | | |
| | Social F1 | 0.85 | | |
| | Governance F1 | 0.79 | | |
| | Non-ESG F1 | 0.84 | | |
| ## π¨ Customization | |
| ### Modify Thresholds | |
| Edit `app.py` or `model.py`: | |
| ```python | |
| CONFIG.thresholds = { | |
| 'E': 0.35, # Lower = more Environmental predictions | |
| 'S': 0.45, # Balanced | |
| 'G': 0.40, # Balanced | |
| 'non_ESG': 0.50 | |
| } | |
| ``` | |
| ### Add Keywords | |
| Extend the keyword lists in `ESGConfig`: | |
| ```python | |
| CONFIG.keywords['E'].extend(['sustainability', 'climate action']) | |
| ``` | |
| ### Custom Styling | |
| Modify `THEME_CSS` in `app.py` for visual customization. | |
| ## π Project Structure | |
| ``` | |
| esg_app/ | |
| βββ app.py # Main Gradio application | |
| βββ model.py # Model inference module | |
| βββ requirements.txt # Python dependencies | |
| βββ README.md # This file | |
| βββ models/ # Saved model weights (optional) | |
| βββ scaler.joblib | |
| βββ lr_E.joblib | |
| βββ lr_S.joblib | |
| βββ lr_G.joblib | |
| βββ lr_non_ESG.joblib | |
| ``` | |
| ## π€ Contributing | |
| 1. Fork the repository | |
| 2. Create a feature branch | |
| 3. Make your changes | |
| 4. Submit a pull request | |
| ## π License | |
| MIT License - Feel free to use and modify! | |
| --- | |
| <div align="center"> | |
| **Built with β€οΈ for ESG Analysis** | |
| πΏ Environmental | π₯ Social | βοΈ Governance | |
| </div> | |