Spaces:
Sleeping
Sleeping
Download setup.py from climatex45678/climatex-api: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/spaces/climatex45678/climatex-api/resolve/main/setup.py
- Command line
-
hf download hf://spaces/climatex45678/climatex-api/setup.py
-
curl -L -o setup.py https://huggingface.co/spaces/climatex45678/climatex-api/resolve/main/setup.py
3.07 kB
| #!/usr/bin/env python3 | |
| """ | |
| KISANSURAKSHA - COMPLETE SYSTEM SETUP & DEPLOYMENT | |
| Run this script to set up the entire application with optimized models and web UI | |
| """ | |
| import subprocess | |
| import sys | |
| import time | |
| from datetime import datetime | |
| def print_banner(text): | |
| print("\n" + "="*80) | |
| print(f" {text}") | |
| print("="*80) | |
| def run_command(cmd, description): | |
| """Run a command and report status""" | |
| print(f"\nβΆοΈ {description}") | |
| print("-" * 80) | |
| try: | |
| result = subprocess.run(cmd, shell=True, capture_output=False) | |
| if result.returncode == 0: | |
| print(f"β {description} - SUCCESS") | |
| return True | |
| else: | |
| print(f"β {description} - FAILED") | |
| return False | |
| except Exception as e: | |
| print(f"β {description} - ERROR: {e}") | |
| return False | |
| def main(): | |
| print_banner("πΎ KISANSURAKSHA - COMPLETE SYSTEM DEPLOYMENT") | |
| print(f"Start Time: {datetime.now()}") | |
| steps = [ | |
| ("py train_optimized.py", "Step 1: Train Optimized ML Models (with hyperparameter tuning)"), | |
| ] | |
| success = True | |
| for cmd, desc in steps: | |
| if not run_command(cmd, desc): | |
| success = False | |
| print(f"\nβ οΈ Continuing despite error...") | |
| if success: | |
| print_banner("β SYSTEM SETUP COMPLETE - READY FOR DEPLOYMENT") | |
| print("\nπ KISANSURAKSHA SYSTEM CONFIGURATION:") | |
| print(""" | |
| β ML Models: Optimized Random Forest Classifiers | |
| β Districts: 36 Maharashtra (All covered) | |
| β Hazards: Drought, Flood, Heat Wave | |
| β Use Cases: 3 (Crop Advisory, Insurance, Credit Risk) | |
| β Data Source: DiCRA API (Real climate data) | |
| β Historical Validation: 2012, 2015, 2016, 2018 | |
| β Feature Engineering: Temporal lags + seasonal patterns | |
| β Hyperparameter Optimization: GridSearchCV enabled | |
| β Model Validation: 5-fold cross-validation | |
| """) | |
| print("\nπ NEXT STEPS:") | |
| print(""" | |
| 1οΈβ£ Start the Web Dashboard: | |
| py web_app.py | |
| 2οΈβ£ Open your browser: | |
| http://localhost:5000 | |
| 3οΈβ£ Use the three decision-ready tools: | |
| β’ Crop Advisory: Get seasonal farming recommendations | |
| β’ Insurance Trigger: Auto-detect PMFBY insurance events | |
| β’ Credit Risk: Assess lending risk for farmers | |
| 4οΈβ£ REST API Endpoints (for integration): | |
| POST /api/v1/forecast - Get hazard scores | |
| POST /api/v1/insurance-trigger - Check insurance | |
| POST /api/v1/credit-risk - Assess credit | |
| GET /api/v1/health - System status | |
| """) | |
| print("\n" + "="*80) | |
| print(f"β End Time: {datetime.now()}") | |
| print("="*80) | |
| else: | |
| print_banner("β οΈ SETUP COMPLETED WITH ISSUES") | |
| if __name__ == '__main__': | |
| main() | |