-
Notifications
You must be signed in to change notification settings - Fork 7
/
yield_prediction.php
235 lines (182 loc) · 7.69 KB
/
yield_prediction.php
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
<!DOCTYPE html>
<html>
<?php include ('header.php'); ?>
<body class="bg-white" id="top">
<?php include ('nav.php'); ?>
<section class="section section-shaped section-lg">
<div class="shape shape-style-1 shape-primary">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<!-- ======================================================================================================================================== -->
<div class="container ">
<div class="row">
<div class="col-md-8 mx-auto text-center">
<span class="badge badge-danger badge-pill mb-3">Prediction</span>
</div>
</div>
<div class="row row-content">
<div class="col-md-12 mb-3">
<div class="card text-white bg-gradient-success mb-3">
<form role="form" action="#" method="post" >
<div class="card-header">
<span class=" text-info display-4" > Yield Prediction </span>
</div>
<div class="card-body text-dark">
<table class="table table-striped table-hover table-bordered bg-gradient-white text-center display" id="myTable">
<thead>
<tr class="font-weight-bold text-default">
<th><center> State</center></th>
<th><center>District</center></th>
<th><center>Season</center></th>
<th><center>Crop</center></th>
<th><center>Area</center></th>
<th><center>Prediction</center></th>
</tr>
</thead>
<tbody>
<tr class="text-center">
<td>
<div class="form-group">
<select name="state" class="form-control" required>
<option value="Karnataka">Karnataka</option>
</select>
</div>
</td>
<td>
<div class="form-group ">
<select id="district" name="district" class="form-control" required>
<option value="">Select a district</option>
<option value="BAGALKOT">Bagalkot</option>
<option value="BANGALORE_RURAL">Bangalore Rural</option>
<option value="BELGAUM">Belgaum</option>
<option value="BELLARY">Bellary</option>
<option value="BENGALURU_URBAN">Bengaluru Urban</option>
<option value="BIDAR">Bidar</option>
<option value="BIJAPUR">Bijapur</option>
<option value="CHAMARAJANAGAR">Chamarajanagar</option>
<option value="CHIKBALLAPUR">Chikballapur</option>
<option value="CHIKMAGALUR">Chikmagalur</option>
<option value="CHITRADURGA">Chitradurga</option>
<option value="DAKSHIN_KANNAD">Dakshin Kannad</option>
<option value="DAVANGERE">Davangere</option>
<option value="DHARWAD">Dharwad</option>
<option value="GADAG">Gadag</option>
<option value="GULBARGA">Gulbarga</option>
<option value="HAVERI">Haveri</option>
<option value="HASSAN">Hassan</option>
<option value="KODAGU">Kodagu</option>
<option value="KOLAR">Kolar</option>
<option value="KOPPAL">Koppal</option>
<option value="MANDYA">Mandya</option>
<option value="MYSORE">Mysore</option>
<option value="RAMANAGARA">Ramanagara</option>
<option value="RAICHUR">Raichur</option>
<option value="SHIMOGA">Shimoga</option>
<option value="TUMKUR">Tumkur</option>
<option value="UDUPI">Udupi</option>
<option value="UTTAR_KANNAD">Uttar Kannad</option>
<option value="YADGIR">Yadgir</option>
</select>
</div>
</td>
<td>
<div class="form-group ">
<select name="Season" class="form-control" id="season" required>
<option value="">Select Season ...</option>
<option name="Kharif" value="Kharif">Kharif</option>
<option name="Rabi" value="Rabi">Rabi</option>
<option name="Summer" value="Summer">Summer</option>
<option name="WholeYear" value="WholeYear">Whole Year</option>
</select>
</div>
</td>
<td>
<div class="form-group" >
<select id="crop" class="form-control" name="crops" required>
<option value="">Select crop</option>
</select>
</div>
</td>
<script>
document.getElementById("season").addEventListener("change", function() {
const districtDropdown = document.getElementById('district');
const seasonDropdown = document.getElementById('season');
const cropDropdown = document.getElementById('crop');
console.log(districtDropdown);
console.log(seasonDropdown);
console.log(cropDropdown);
const selectedDistrict = districtDropdown.value;
const selectedSeason = seasonDropdown.value;
// Clear the current crop options
cropDropdown.innerHTML = '<option value="">Select crop</option>';
// If both district and season are selected, add the corresponding crop options to the dropdown
if (selectedDistrict && selectedSeason) {
const options = cropOptions[selectedDistrict][selectedSeason];
for (const option of options) {
const optionElement = document.createElement('option');
optionElement.value = option; // Set the value to the option text
optionElement.text = option;
cropDropdown.appendChild(optionElement);
}
}
});
</script>
<td>
<div class="form-group">
<input type = "number" step=0.01 name="area" placeholder="Area in Hectares" required class="form-control">
</div>
</td>
<td>
<center>
<div class="form-group ">
<button type="submit" value="Yield" name="Yield_Predict" class="btn btn-success btn-submit">Predict</button>
</div>
</center>
</td>
</tr>
</tbody>
</table>
</div>
</form>
</div>
<div class="card text-white bg-gradient-success mb-3">
<div class="card-header">
<span class=" text-success display-4" > Result </span>
</div>
<h4>
<?php
if(isset($_POST['Yield_Predict'])){
$state=trim($_POST['state']);
$district=trim($_POST['district']);
$season=trim($_POST['Season']);
$crops=trim($_POST['crops']);
$area=trim($_POST['area']);
echo "Predicted crop yield (in Quintal) is: ";
$Jstate=json_encode($state);
$Jdistrict=json_encode($district);
$Jseason=json_encode($season);
$Jcrops=json_encode($crops);
$Jarea=json_encode($area);
$command = escapeshellcmd("python ML/yield_prediction/yield_prediction.py $Jstate $Jdistrict $Jseason $Jcrops $Jarea ");
$output = passthru($command);
echo $output;
}
?>
</h4>
</div>
</div>
</div>
</div>
</section>
<?php require("footer.php");?>
</body>
</html>