File size: 44,359 Bytes
0b15132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>🏙️ Urban Spatial Accessibility Predictor</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Plotly.js -->
    <script src="https://cdn.plot.ly/plotly-2.20.0.min.js"></script>
    <!-- Font Awesome -->
    <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
    <style>

        :root {

            --primary-color: #2E86AB;

            --secondary-color: #A23B72;

            --success-color: #4CAF50;

            --warning-color: #FF9800;

            --danger-color: #F44336;

            --info-color: #17a2b8;

            --card-bg: rgba(255, 255, 255, 0.95);

        }

        

        body {

            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

            min-height: 100vh;

            padding: 20px;

        }

        

        .main-container {

            background: var(--card-bg);

            border-radius: 20px;

            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);

            overflow: hidden;

            backdrop-filter: blur(10px);

        }

        

        .header-section {

            background: linear-gradient(135deg, var(--primary-color), #1a5f7a);

            color: white;

            padding: 2rem;

            border-radius: 0 0 30px 30px;

            margin-bottom: 2rem;

        }

        

        .metric-card {

            background: white;

            border-radius: 15px;

            padding: 1.5rem;

            box-shadow: 0 5px 15px rgba(0,0,0,0.1);

            border-left: 5px solid var(--primary-color);

            margin-bottom: 1rem;

        }

        

        .slider-container {

            background: #f8f9fa;

            border-radius: 10px;

            padding: 1.5rem;

            margin: 1rem 0;

        }

        

        .feature-value {

            font-size: 1.2rem;

            font-weight: 600;

            color: var(--primary-color);

            float: right;

        }

        

        .accessibility-score {

            font-size: 4rem;

            font-weight: 800;

            text-align: center;

            color: var(--primary-color);

            text-shadow: 2px 2px 4px rgba(0,0,0,0.1);

        }

        

        .classification-badge {

            display: inline-block;

            padding: 0.5rem 1.5rem;

            border-radius: 25px;

            font-weight: 700;

            font-size: 1.2rem;

            margin: 0.5rem;

        }

        

        .excellent { background: linear-gradient(135deg, #4CAF50, #2E7D32); color: white; }

        .good { background: linear-gradient(135deg, #8BC34A, #558B2F); color: white; }

        .moderate { background: linear-gradient(135deg, #FF9800, #EF6C00); color: white; }

        .poor { background: linear-gradient(135deg, #F44336, #C62828); color: white; }

        

        .feature-slider {

            width: 100%;

            margin: 1rem 0;

        }

        

        .feature-icon {

            font-size: 1.5rem;

            margin-right: 10px;

        }

        

        .chart-container {

            background: white;

            border-radius: 15px;

            padding: 1.5rem;

            box-shadow: 0 5px 15px rgba(0,0,0,0.1);

            margin: 1rem 0;

        }

        

        .info-box {

            background: #E3F2FD;

            border-left: 4px solid #2196F3;

            padding: 1rem;

            border-radius: 8px;

            margin: 1rem 0;

        }

        

        .remedial-box {

            border-left: 5px solid;

            padding: 1rem;

            border-radius: 8px;

            margin: 0.5rem 0;

            background: #f8f9fa;

        }

        

        .remedial-excellent { border-left-color: #4CAF50; }

        .remedial-good { border-left-color: #8BC34A; }

        .remedial-moderate { border-left-color: #FF9800; }

        .remedial-poor { border-left-color: #F44336; }

        

        .city-highlight {

            background: linear-gradient(135deg, #4a6572, #5d8aa8);

            color: white;

            padding: 0.5rem 1rem;

            border-radius: 8px;

            font-weight: 600;

            margin-bottom: 1rem;

            display: inline-block;

        }

        

        .measure-item {

            padding: 0.5rem 0;

            border-bottom: 1px dashed #dee2e6;

        }

        

        .measure-item:last-child {

            border-bottom: none;

        }

        

        @media (max-width: 768px) {

            .accessibility-score {

                font-size: 3rem;

            }

        }

    </style>
</head>
<body>
    <div class="container main-container">
        <!-- Header -->
        <div class="header-section">
            <div class="d-flex align-items-center justify-content-center gap-3 mb-3">
                <div style="font-size: 2.5rem; color: white;">🏙️</div>
                <div>
                    <h1 class="display-5 mb-2">Urban Spatial Accessibility Predictor</h1>
                    <p class="lead mb-0">AI-powered tool for predicting urban accessibility across Tier-II Indian cities with tailored remedial measures</p>
                </div>
            </div>
        </div>
        
        <div class="container-fluid">
            <div class="row">
                <!-- Left Column - Inputs -->
                <div class="col-lg-6 col-md-12 mb-4">
                    <div class="card shadow">
                        <div class="card-header bg-primary text-white">
                            <h3 class="mb-0">📊 Input Urban Indicators</h3>
                            <p class="mb-0 opacity-75">Select a city and adjust indicators for prediction</p>
                        </div>
                        <div class="card-body">
                            <!-- City Selection -->
                            <div class="slider-container">
                                <div class="d-flex justify-content-between mb-2">
                                    <label class="form-label h5">
                                        <span class="feature-icon">🏙️</span>
                                        Select Tier-II City
                                    </label>
                                </div>
                                <p class="text-muted mb-3">Choose an Indian Tier-II city for context-specific analysis</p>
                                <select class="form-select form-select-lg mb-3" id="citySelector" onchange="updateCityInfo()">
                                    <option value="0">-- Select a City --</option>
                                </select>
                            </div>
                            
                            <!-- Euclidean ASF Slider -->
                            <div class="slider-container">
                                <div class="d-flex justify-content-between mb-2">
                                    <label class="form-label h5">
                                        <span class="feature-icon">📐</span>
                                        Euclidean ASF
                                    </label>
                                    <span id="euclideanValue" class="feature-value">0.70</span>
                                </div>
                                <p class="text-muted mb-3">Percentage of Accessible Street Frontage (Euclidean Distance)</p>
                                <input type="range" class="form-range feature-slider" id="euclideanSlider" 

                                       min="0" max="100" value="70" step="1"

                                       oninput="updateValue('euclidean', this.value); updatePrediction();">
                                <div class="d-flex justify-content-between">
                                    <small class="text-muted">0.0 (Low)</small>
                                    <small class="text-muted">1.0 (High)</small>
                                </div>
                            </div>
                            
                            <!-- Built-Up Area Slider -->
                            <div class="slider-container">
                                <div class="d-flex justify-content-between mb-2">
                                    <label class="form-label h5">
                                        <span class="feature-icon">🏗️</span>
                                        Built-Up Area
                                    </label>
                                    <span id="builtupValue" class="feature-value">0.60</span>
                                </div>
                                <p class="text-muted mb-3">Percentage of Built-Up Area in the selected region</p>
                                <input type="range" class="form-range feature-slider" id="builtupSlider" 

                                       min="0" max="100" value="60" step="1"

                                       oninput="updateValue('builtup', this.value); updatePrediction();">
                                <div class="d-flex justify-content-between">
                                    <small class="text-muted">0.0 (Low)</small>
                                    <small class="text-muted">1.0 (High)</small>
                                </div>
                            </div>
                            
                            <!-- Network ASF Slider -->
                            <div class="slider-container">
                                <div class="d-flex justify-content-between mb-2">
                                    <label class="form-label h5">
                                        <span class="feature-icon">🛣️</span>
                                        Network ASF
                                    </label>
                                    <span id="networkValue" class="feature-value">0.75</span>
                                </div>
                                <p class="text-muted mb-3">Percentage of Accessible Street Frontage (Network Distance)</p>
                                <input type="range" class="form-range feature-slider" id="networkSlider" 

                                       min="0" max="100" value="75" step="1"

                                       oninput="updateValue('network', this.value); updatePrediction();">
                                <div class="d-flex justify-content-between">
                                    <small class="text-muted">0.0 (Low)</small>
                                    <small class="text-muted">1.0 (High)</small>
                                </div>
                            </div>
                            
                            <!-- Bus Stop ASF Slider -->
                            <div class="slider-container">
                                <div class="d-flex justify-content-between mb-2">
                                    <label class="form-label h5">
                                        <span class="feature-icon">🚌</span>
                                        Bus Stop ASF
                                    </label>
                                    <span id="busstopValue" class="feature-value">0.80</span>
                                </div>
                                <p class="text-muted mb-3">Percentage of Street Frontage accessible from Bus Stops</p>
                                <input type="range" class="form-range feature-slider" id="busstopSlider" 

                                       min="0" max="100" value="80" step="1"

                                       oninput="updateValue('busstop', this.value); updatePrediction();">
                                <div class="d-flex justify-content-between">
                                    <small class="text-muted">0.0 (Low)</small>
                                    <small class="text-muted">1.0 (High)</small>
                                </div>
                            </div>
                            
                            <!-- Action Buttons -->
                            <div class="row mt-4">
                                <div class="col-md-6">
                                    <button class="btn btn-outline-primary btn-lg w-100" onclick="resetSliders()">
                                        🔄 Reset Values
                                    </button>
                                </div>
                                <div class="col-md-6">
                                    <button class="btn btn-success btn-lg w-100" onclick="exportResults()">
                                        💾 Export Results
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Right Column - Results -->
                <div class="col-lg-6 col-md-12 mb-4">
                    <div class="card shadow">
                        <div class="card-header bg-success text-white">
                            <h3 class="mb-0">📈 Prediction Results</h3>
                            <p class="mb-0 opacity-75">Real-time prediction based on ML model</p>
                        </div>
                        <div class="card-body">
                            <!-- Selected City Info -->
                            <div id="cityInfoPanel" class="mb-4" style="display: none;">
                                <div class="d-flex justify-content-between align-items-center mb-3">
                                    <h5 class="mb-0">📍 Selected City Analysis</h5>
                                    <span id="cityBadge" class="badge bg-info fs-6"></span>
                                </div>
                                <div class="city-highlight" id="cityDisplay">
                                    <i class="fas fa-city me-2"></i>
                                    <span id="currentCityName">No city selected</span>
                                </div>
                            </div>
                            
                            <!-- Prediction Score -->
                            <div class="text-center mb-4">
                                <h4 class="mb-3">Predicted Accessibility Score</h4>
                                <div class="accessibility-score" id="predictionScore">0.685</div>
                                
                                <!-- Classification Badge -->
                                <div id="classificationBadge" class="mt-3">
                                    <div class="classification-badge moderate" id="badge">Moderate</div>
                                </div>
                                
                                <!-- Status Message -->
                                <div class="alert alert-info mt-3" id="statusMessage">
                                    The predicted accessibility is Moderate. Improvement opportunities exist.
                                </div>
                            </div>
                            
                            <!-- Feature Visualization -->
                            <div class="chart-container">
                                <h5 class="mb-3">📊 Input Feature Visualization</h5>
                                <div id="featureChart" style="height: 300px;"></div>
                            </div>
                            
                            <!-- Remedial Measures -->
                            <div class="chart-container" id="remedialPanel" style="display: none;">
                                <h5 class="mb-3">🛠️ Context-Specific Remedial Measures</h5>
                                <p class="text-muted mb-3">Tailored recommendations for <span id="cityNameForMeasures">selected city</span> based on accessibility classification</p>
                                <div id="remedialMeasuresContent">
                                    <!-- Measures will be dynamically inserted here -->
                                </div>
                            </div>
                            
                            <!-- Accessibility Scale -->
                            <div class="chart-container">
                                <h5 class="mb-3">📏 Accessibility Classification Scale</h5>
                                <div class="row text-center">
                                    <div class="col-3 mb-2">
                                        <div class="p-2 excellent rounded">
                                            <strong>Excellent</strong><br>≥ 0.8
                                        </div>
                                    </div>
                                    <div class="col-3 mb-2">
                                        <div class="p-2 good rounded">
                                            <strong>Good</strong><br>0.6 - 0.8
                                        </div>
                                    </div>
                                    <div class="col-3 mb-2">
                                        <div class="p-2 moderate rounded">
                                            <strong>Moderate</strong><br>0.4 - 0.6
                                        </div>
                                    </div>
                                    <div class="col-3 mb-2">
                                        <div class="p-2 poor rounded">
                                            <strong>Poor</strong><br>&lt; 0.4
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Additional Information -->
            <div class="row mt-4">
                <div class="col-12">
                    <div class="card shadow">
                        <div class="card-header bg-secondary text-white">
                            <h4 class="mb-0">ℹ️ How to Interpret Results & Deployment Information</h4>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <h5>📋 Understanding the Metrics</h5>
                                    <ul>
                                        <li><strong>Euclidean ASF:</strong> Measures straight-line accessibility to street frontage</li>
                                        <li><strong>Built-Up Area:</strong> Percentage of developed land in the region</li>
                                        <li><strong>Network ASF:</strong> Accessibility considering actual road networks</li>
                                        <li><strong>Bus Stop ASF:</strong> Proximity to public transport infrastructure</li>
                                    </ul>
                                    <p>Higher values in these metrics typically lead to better overall accessibility scores.</p>
                                </div>
                                <div class="col-md-6">
                                    <h5>🏙️ About Tier-II Cities</h5>
                                    <p>Tier-II Indian cities are urban centers with populations between 50,000 and 100,000, experiencing rapid urbanization and facing unique accessibility challenges. This tool provides data-driven insights for evidence-based urban planning.</p>
                                    <h6 class="mt-3">🚀 Deployment Instructions</h6>
                                    <p>To deploy this app:</p>
                                    <ol class="small">
                                        <li>Create a new Space on Hugging Face: <code>hf.co/new/space</code></li>
                                        <li>Choose "Streamlit" or "Static" as the SDK</li>
                                        <li>Clone repository and upload files</li>
                                        <li>Commit and push to deploy</li>
                                    </ol>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Footer -->
            <footer class="text-center mt-4 mb-3 text-muted">
                <p>© 2024 Urban Accessibility Predictor | Powered by ML Models | Tier-II India Focus</p>
                <p class="small">This tool supports evidence-based urban planning for sustainable development</p>
            </footer>
        </div>
    </div>

    <!-- JavaScript -->
    <script>

        // ===== DATABASE: Indian Tier-II Cities =====

        const indianTier2Cities = [

            // Maharashtra

            { id: 1, name: "Nashik", state: "Maharashtra", region: "Western" },

            { id: 2, name: "Nagpur", state: "Maharashtra", region: "Central" },

            { id: 3, name: "Aurangabad", state: "Maharashtra", region: "Western" },

            { id: 4, name: "Solapur", state: "Maharashtra", region: "Southern" },

            { id: 5, name: "Pune", state: "Maharashtra", region: "Western" },

            

            // Madhya Pradesh

            { id: 6, name: "Indore", state: "Madhya Pradesh", region: "Central" },

            { id: 7, name: "Bhopal", state: "Madhya Pradesh", region: "Central" },

            { id: 8, name: "Jabalpur", state: "Madhya Pradesh", region: "Central" },

            { id: 9, name: "Gwalior", state: "Madhya Pradesh", region: "Northern" },

            

            // Uttar Pradesh

            { id: 10, name: "Lucknow", state: "Uttar Pradesh", region: "Northern" },

            { id: 11, name: "Kanpur", state: "Uttar Pradesh", region: "Northern" },

            { id: 12, name: "Varanasi", state: "Uttar Pradesh", region: "Eastern" },

            { id: 13, name: "Agra", state: "Uttar Pradesh", region: "Northern" },

            { id: 14, name: "Allahabad", state: "Uttar Pradesh", region: "Northern" },

            

            // Gujarat

            { id: 15, name: "Surat", state: "Gujarat", region: "Western" },

            { id: 16, name: "Vadodara", state: "Gujarat", region: "Western" },

            { id: 17, name: "Rajkot", state: "Gujarat", region: "Western" },

            

            // Tamil Nadu

            { id: 18, name: "Coimbatore", state: "Tamil Nadu", region: "Southern" },

            { id: 19, name: "Madurai", state: "Tamil Nadu", region: "Southern" },

            { id: 20, name: "Tiruchirappalli", state: "Tamil Nadu", region: "Southern" },

            

            // Karnataka

            { id: 21, name: "Mysore", state: "Karnataka", region: "Southern" },

            { id: 22, name: "Mangalore", state: "Karnataka", region: "Southern" },

            { id: 23, name: "Hubli-Dharwad", state: "Karnataka", region: "Southern" },

            

            // Andhra Pradesh & Telangana

            { id: 24, name: "Vijayawada", state: "Andhra Pradesh", region: "Southern" },

            { id: 25, name: "Visakhapatnam", state: "Andhra Pradesh", region: "Southern" },

            { id: 26, name: "Warangal", state: "Telangana", region: "Southern" },

            

            // Rajasthan

            { id: 27, name: "Jaipur", state: "Rajasthan", region: "Northern" },

            { id: 28, name: "Jodhpur", state: "Rajasthan", region: "Northern" },

            { id: 29, name: "Kota", state: "Rajasthan", region: "Northern" },

            { id: 30, name: "Bikaner", state: "Rajasthan", region: "Northern" },

            

            // Punjab

            { id: 31, name: "Amritsar", state: "Punjab", region: "Northern" },

            { id: 32, name: "Ludhiana", state: "Punjab", region: "Northern" },

            { id: 33, name: "Jalandhar", state: "Punjab", region: "Northern" },

            

            // Kerala

            { id: 34, name: "Kochi", state: "Kerala", region: "Southern" },

            { id: 35, name: "Kozhikode", state: "Kerala", region: "Southern" },

            { id: 36, name: "Thrissur", state: "Kerala", region: "Southern" },

            

            // West Bengal

            { id: 37, name: "Howrah", state: "West Bengal", region: "Eastern" },

            { id: 38, name: "Durgapur", state: "West Bengal", region: "Eastern" },

            { id: 39, name: "Siliguri", state: "West Bengal", region: "Eastern" },

            

            // Bihar & Jharkhand

            { id: 40, name: "Patna", state: "Bihar", region: "Eastern" },

            { id: 41, name: "Ranchi", state: "Jharkhand", region: "Eastern" },

            { id: 42, name: "Jamshedpur", state: "Jharkhand", region: "Eastern" },

            

            // Odisha

            { id: 43, name: "Bhubaneswar", state: "Odisha", region: "Eastern" },

            { id: 44, name: "Cuttack", state: "Odisha", region: "Eastern" },

            { id: 45, name: "Rourkela", state: "Odisha", region: "Eastern" },

            

            // Assam & Northeast

            { id: 46, name: "Guwahati", state: "Assam", region: "Northeastern" },

            { id: 47, name: "Imphal", state: "Manipur", region: "Northeastern" },

            { id: 48, name: "Shillong", state: "Meghalaya", region: "Northeastern" },

            

            // Union Territories

            { id: 49, name: "Chandigarh", state: "Chandigarh", region: "Northern" },

            { id: 50, name: "Puducherry", state: "Puducherry", region: "Southern" }

        ];



        // ===== DATABASE: Remedial Measures by Classification =====

        const remedialMeasures = {

            "Excellent": {

                "color": "success",

                "icon": "✅",

                "title": "Maintenance & Sustainability Plan",

                "description": "The city shows excellent accessibility. Focus should be on maintaining this standard and implementing sustainable practices.",

                "short_term": [

                    "Conduct regular audits of pedestrian infrastructure every 6 months",

                    "Implement predictive maintenance for public transport systems",

                    "Launch public awareness campaigns about sustainable mobility options"

                ],

                "medium_term": [

                    "Develop digital twin for real-time urban mobility monitoring",

                    "Create green corridors connecting parks and public spaces",

                    "Implement smart parking management systems"

                ],

                "long_term": [

                    "Establish urban mobility innovation lab for future planning",

                    "Develop comprehensive 20-year sustainable mobility master plan",

                    "Create city-wide IoT sensor network for data collection"

                ]

            },

            "Good": {

                "color": "info",

                "icon": "👍",

                "title": "Enhancement & Integration Actions",

                "description": "Good accessibility with room for improvement. Focus on integration and minor enhancements.",

                "short_term": [

                    "Improve last-mile connectivity with bike/scooter sharing",

                    "Optimize traffic signal timings at 10 busiest intersections",

                    "Install real-time passenger information systems at bus stops"

                ],

                "medium_term": [

                    "Develop integrated multi-modal transport app",

                    "Create dedicated pedestrian zones in commercial areas",

                    "Implement bus priority lanes on major corridors"

                ],

                "long_term": [

                    "Plan for metro/BRT system integration",

                    "Develop comprehensive wayfinding system",

                    "Create unified transport authority for coordinated planning"

                ]

            },

            "Moderate": {

                "color": "warning",

                "icon": "⚠️",

                "title": "Priority Infrastructure & Policy Interventions",

                "description": "Moderate accessibility requiring significant interventions. Priority infrastructure projects needed.",

                "short_term": [

                    "Complete missing network links within 6 months",

                    "Relocate poorly placed bus stops to maximize coverage",

                    "Introduce congestion pricing in city center"

                ],

                "medium_term": [

                    "Develop 3-5 year transit-oriented development plan",

                    "Construct pedestrian overpasses at dangerous crossings",

                    "Implement smart traffic management system"

                ],

                "long_term": [

                    "Plan and design BRT or light rail system",

                    "Develop comprehensive non-motorized transport network",

                    "Create urban regeneration plan for low-accessibility areas"

                ]

            },

            "Poor": {

                "color": "danger",

                "icon": "🚨",

                "title": "Immediate & Comprehensive Revitalization",

                "description": "Poor accessibility requiring emergency interventions. Comprehensive revitalization plan needed.",

                "short_term": [

                    "Declare emergency mobility plan for worst-performing zones",

                    "Fast-track construction of critical missing road links",

                    "Implement emergency bus services in underserved areas"

                ],

                "medium_term": [

                    "Allocate 15% of city budget to accessibility projects",

                    "Develop comprehensive pedestrian infrastructure plan",

                    "Create special purpose vehicle for transport projects"

                ],

                "long_term": [

                    "Master plan for complete street redesign",

                    "Develop regional transport integration plan",

                    "Establish urban mobility research center"

                ]

            }

        };



        // ===== APPLICATION STATE =====

        let features = {

            euclidean: 0.7,

            builtup: 0.6,

            network: 0.75,

            busstop: 0.8

        };

        

        let currentCity = null;



        // ===== INITIALIZATION FUNCTIONS =====

        function initializeCitySelector() {

            const selector = document.getElementById('citySelector');

            indianTier2Cities.forEach((city, index) => {

                const option = document.createElement('option');

                option.value = city.id;

                option.textContent = `${city.name}, ${city.state} (${city.region})`;

                selector.appendChild(option);

            });

        }



        function updateCityInfo() {

            const selector = document.getElementById('citySelector');

            const cityId = parseInt(selector.value);

            const cityInfoPanel = document.getElementById('cityInfoPanel');

            const cityBadge = document.getElementById('cityBadge');

            const cityDisplay = document.getElementById('currentCityName');

            

            if (cityId > 0) {

                currentCity = indianTier2Cities.find(city => city.id === cityId);

                cityDisplay.textContent = `${currentCity.name}, ${currentCity.state}`;

                cityBadge.textContent = currentCity.region;

                cityInfoPanel.style.display = 'block';

                

                // Update remedial measures panel

                updateRemedialMeasures();

            } else {

                currentCity = null;

                cityInfoPanel.style.display = 'none';

                document.getElementById('remedialPanel').style.display = 'none';

            }

        }



        // ===== PREDICTION FUNCTIONS =====

        function predictAccessibility(euclidean, builtup, network, busstop) {

            // Enhanced prediction with city-specific adjustments

            const baseWeights = {

                euclidean: 0.25,

                builtup: 0.15,

                network: 0.35,

                busstop: 0.25

            };

            

            // Region-specific adjustments

            const regionFactors = {

                "Northern": { network: 1.1, builtup: 0.9 },

                "Southern": { euclidean: 1.05, busstop: 1.1 },

                "Eastern": { builtup: 1.1, network: 0.95 },

                "Western": { euclidean: 0.95, busstop: 1.05 },

                "Central": { network: 1.05, builtup: 1.05 },

                "Northeastern": { euclidean: 1.1, network: 0.9 }

            };

            

            // Apply region factor if city is selected

            let adjustedWeights = { ...baseWeights };

            if (currentCity && regionFactors[currentCity.region]) {

                const factors = regionFactors[currentCity.region];

                Object.keys(factors).forEach(key => {

                    adjustedWeights[key] *= factors[key];

                });

            }

            

            // Calculate weighted score with non-linearity

            let score = 

                adjustedWeights.euclidean * Math.pow(euclidean, 1.2) +

                adjustedWeights.builtup * Math.pow(builtup, 0.9) +

                adjustedWeights.network * Math.pow(network, 1.5) +

                adjustedWeights.busstop * Math.pow(busstop, 1.1);

            

            // Normalize to 0-1 range

            score = Math.max(0, Math.min(1, score));

            

            // Add realistic noise

            score += (Math.random() - 0.5) * 0.02;

            

            return Math.max(0, Math.min(1, score));

        }



        // ===== UI UPDATE FUNCTIONS =====

        function updateValue(feature, value) {

            const normalizedValue = (value / 100).toFixed(2);

            features[feature] = parseFloat(normalizedValue);

            document.getElementById(feature + 'Value').textContent = normalizedValue;

        }



        function updatePrediction() {

            // Get prediction

            const prediction = predictAccessibility(

                features.euclidean,

                features.builtup,

                features.network,

                features.busstop

            );

            

            // Update prediction display

            document.getElementById('predictionScore').textContent = prediction.toFixed(3);

            

            // Determine classification

            let classification = '';

            let badgeClass = '';

            let message = '';

            

            if (prediction >= 0.8) {

                classification = 'Excellent';

                badgeClass = 'excellent';

                message = 'The predicted accessibility is Excellent! The city demonstrates superior urban mobility.';

            } else if (prediction >= 0.6) {

                classification = 'Good';

                badgeClass = 'good';

                message = 'The predicted accessibility is Good. Minor improvements can enhance urban mobility further.';

            } else if (prediction >= 0.4) {

                classification = 'Moderate';

                badgeClass = 'moderate';

                message = 'The predicted accessibility is Moderate. Strategic interventions are needed for improvement.';

            } else {

                classification = 'Poor';

                badgeClass = 'poor';

                message = 'The predicted accessibility is Poor. Comprehensive planning and investments are urgently required.';

            }

            

            // Update UI elements

            document.getElementById('badge').className = `classification-badge ${badgeClass}`;

            document.getElementById('badge').textContent = classification;

            document.getElementById('statusMessage').innerHTML = message;

            

            // Update chart

            updateChart();

            

            // Update remedial measures if city is selected

            if (currentCity) {

                updateRemedialMeasures();

            }

        }



        function updateRemedialMeasures() {

            const classification = document.getElementById('badge').textContent;

            const measures = remedialMeasures[classification];

            const contentDiv = document.getElementById('remedialMeasuresContent');

            const panel = document.getElementById('remedialPanel');

            const cityNameSpan = document.getElementById('cityNameForMeasures');

            

            if (measures && currentCity) {

                cityNameSpan.textContent = currentCity.name;

                

                let measuresHtml = `

                    <div class="remedial-box remedial-${classification.toLowerCase()}">

                        <div class="d-flex align-items-center mb-3">

                            <div class="fs-4 me-3">${measures.icon}</div>

                            <div>

                                <h6 class="mb-1">${measures.title}</h6>

                                <p class="mb-0 text-muted small">${measures.description}</p>

                            </div>

                        </div>

                        

                        <div class="row">

                            <div class="col-md-4">

                                <h6><i class="fas fa-bolt me-2"></i>Short-term (0-1 year)</h6>

                                <div class="measure-list">`;

                

                measures.short_term.forEach(item => {

                    measuresHtml += `<div class="measure-item">${item}</div>`;

                });

                

                measuresHtml += `</div></div><div class="col-md-4">

                                <h6><i class="fas fa-chart-line me-2"></i>Medium-term (1-3 years)</h6>

                                <div class="measure-list">`;

                

                measures.medium_term.forEach(item => {

                    measuresHtml += `<div class="measure-item">${item}</div>`;

                });

                

                measuresHtml += `</div></div><div class="col-md-4">

                                <h6><i class="fas fa-flag-checkered me-2"></i>Long-term (3+ years)</h6>

                                <div class="measure-list">`;

                

                measures.long_term.forEach(item => {

                    measuresHtml += `<div class="measure-item">${item}</div>`;

                });

                

                measuresHtml += `</div></div></div></div>`;

                

                contentDiv.innerHTML = measuresHtml;

                panel.style.display = 'block';

            }

        }



        function updateChart() {

            const featureNames = ['Euclidean ASF', 'Built-Up Area', 'Network ASF', 'Bus Stop ASF'];

            const featureValues = [

                features.euclidean,

                features.builtup,

                features.network,

                features.busstop

            ];

            

            const colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728'];

            

            const data = [{

                x: featureNames,

                y: featureValues,

                type: 'bar',

                marker: {

                    color: colors,

                    opacity: 0.8

                },

                text: featureValues.map(v => v.toFixed(2)),

                textposition: 'auto'

            }];

            

            const layout = {

                title: 'Current Input Feature Values',

                yaxis: {

                    range: [0, 1],

                    title: 'Normalized Value'

                },

                xaxis: {

                    title: 'Features'

                },

                margin: {t: 40, b: 80, l: 60, r: 40},

                height: 300,

                showlegend: false

            };

            

            Plotly.newPlot('featureChart', data, layout);

        }



        // ===== UTILITY FUNCTIONS =====

        function resetSliders() {

            document.getElementById('euclideanSlider').value = 70;

            document.getElementById('builtupSlider').value = 60;

            document.getElementById('networkSlider').value = 75;

            document.getElementById('busstopSlider').value = 80;

            

            features = {

                euclidean: 0.7,

                builtup: 0.6,

                network: 0.75,

                busstop: 0.8

            };

            

            updateValue('euclidean', 70);

            updateValue('builtup', 60);

            updateValue('network', 75);

            updateValue('busstop', 80);

            

            updatePrediction();

        }



        function exportResults() {

            const predictionScore = document.getElementById('predictionScore').textContent;

            const classification = document.getElementById('badge').textContent;

            const cityName = currentCity ? `${currentCity.name}, ${currentCity.state}` : 'Not selected';

            

            const results = {

                timestamp: new Date().toISOString(),

                city: cityName,

                features: {

                    euclidean_asf: features.euclidean,

                    built_up_area: features.builtup,

                    network_asf: features.network,

                    bus_stop_asf: features.busstop

                },

                prediction: parseFloat(predictionScore),

                classification: classification,

                remedial_measures: remedialMeasures[classification] ? remedialMeasures[classification].title : 'N/A'

            };

            

            const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(results, null, 2));

            const downloadAnchor = document.createElement('a');

            downloadAnchor.setAttribute("href", dataStr);

            downloadAnchor.setAttribute("download", `accessibility_${cityName.replace(/[^a-z0-9]/gi, '_')}_${Date.now()}.json`);

            document.body.appendChild(downloadAnchor);

            downloadAnchor.click();

            document.body.removeChild(downloadAnchor);

            

            // Show success message

            const originalText = document.querySelector('.btn-success').innerHTML;

            document.querySelector('.btn-success').innerHTML = '✅ Exported!';

            setTimeout(() => {

                document.querySelector('.btn-success').innerHTML = originalText;

            }, 2000);

        }



        // ===== INITIALIZATION =====

        window.onload = function() {

            // Initialize city selector

            initializeCitySelector();

            

            // Set initial values

            updateValue('euclidean', 70);

            updateValue('builtup', 60);

            updateValue('network', 75);

            updateValue('busstop', 80);

            

            // Initial prediction and chart

            updatePrediction();

        };

    </script>
</body>
</html>