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()