Spaces:
Sleeping
Sleeping
File size: 3,067 Bytes
32cdc66 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #!/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()
|