lively06 commited on
Commit
731ab0d
1 Parent(s): d00a749
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python 3.9 image
2
+ FROM python:3.9
3
+
4
+ # Set the working directory to /code
5
+ WORKDIR /code
6
+
7
+ # Copy the current directory contents into the container at /code
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ # Install requirements.txt
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
+
13
+ # Set up a new user named "user" with user ID 1000
14
+ RUN useradd -m -u 1000 user
15
+ # Switch to the "user" user
16
+ USER user
17
+ # Set home to the user's home directory
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
+
21
+ # Set the working directory to the user's home directory
22
+ WORKDIR $HOME/app
23
+
24
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
25
+ COPY --chown=user . $HOME/app
26
+
27
+ # Start the FastAPI app on port 7860, the default port expected by Spaces
28
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
Flight Dataset/Data_Train.xlsx ADDED
Binary file (530 kB). View file
 
Flight Dataset/Sample_submission.xlsx ADDED
Binary file (28.5 kB). View file
 
Flight Dataset/Test_set.xlsx ADDED
Binary file (121 kB). View file
 
analysis.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask,request,render_template
2
+ from flask_cors import cross_origin
3
+ import pickle
4
+ import pandas as pd
5
+
6
+
7
+ model = pickle.load(open('flight_rf.pkl','rb'))
8
+
9
+ app = Flask(__name__)
10
+
11
+ @app.route('/')
12
+ @cross_origin()
13
+ def home():
14
+ return render_template('home.html')
15
+
16
+ @app.route('/predict',methods=['GET','POST'])
17
+ @cross_origin()
18
+ def predict():
19
+ if request.method=='POST':
20
+ dep_time = request.form['Dep_Time']
21
+
22
+ Journey_day = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").day
23
+ Journey_month = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").month
24
+
25
+ Departure_hour = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").hour
26
+ Departure_min = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").minute
27
+
28
+ arrival_time = request.form['Arrival_Time']
29
+ Arrival_hour = pd.to_datetime(arrival_time,format="%Y-%m-%dT%H:%M").hour
30
+ Arrival_min = pd.to_datetime(arrival_time,format="%Y-%m-%dT%H:%M").minute
31
+
32
+ Total_stops = int(request.form['stops'])
33
+
34
+ dur_hour = abs(Arrival_hour-Departure_hour)
35
+ dur_min = abs(Arrival_min-Departure_min)
36
+
37
+ airline=request.form['airline']
38
+ if(airline=='Jet Airways'):
39
+ Jet_Airways = 1
40
+ IndiGo = 0
41
+ Air_India = 0
42
+ Multiple_carriers = 0
43
+ SpiceJet = 0
44
+ Vistara = 0
45
+ GoAir = 0
46
+ Multiple_carriers_Premium_economy = 0
47
+ Jet_Airways_Business = 0
48
+ Vistara_Premium_economy = 0
49
+ Trujet = 0
50
+
51
+ elif (airline=='IndiGo'):
52
+ Jet_Airways = 0
53
+ IndiGo = 1
54
+ Air_India = 0
55
+ Multiple_carriers = 0
56
+ SpiceJet = 0
57
+ Vistara = 0
58
+ GoAir = 0
59
+ Multiple_carriers_Premium_economy = 0
60
+ Jet_Airways_Business = 0
61
+ Vistara_Premium_economy = 0
62
+ Trujet = 0
63
+
64
+ elif (airline=='Air India'):
65
+ Jet_Airways = 0
66
+ IndiGo = 0
67
+ Air_India = 1
68
+ Multiple_carriers = 0
69
+ SpiceJet = 0
70
+ Vistara = 0
71
+ GoAir = 0
72
+ Multiple_carriers_Premium_economy = 0
73
+ Jet_Airways_Business = 0
74
+ Vistara_Premium_economy = 0
75
+ Trujet = 0
76
+
77
+ elif (airline=='Multiple carriers'):
78
+ Jet_Airways = 0
79
+ IndiGo = 0
80
+ Air_India = 0
81
+ Multiple_carriers = 1
82
+ SpiceJet = 0
83
+ Vistara = 0
84
+ GoAir = 0
85
+ Multiple_carriers_Premium_economy = 0
86
+ Jet_Airways_Business = 0
87
+ Vistara_Premium_economy = 0
88
+ Trujet = 0
89
+
90
+ elif (airline=='SpiceJet'):
91
+ Jet_Airways = 0
92
+ IndiGo = 0
93
+ Air_India = 0
94
+ Multiple_carriers = 0
95
+ SpiceJet = 1
96
+ Vistara = 0
97
+ GoAir = 0
98
+ Multiple_carriers_Premium_economy = 0
99
+ Jet_Airways_Business = 0
100
+ Vistara_Premium_economy = 0
101
+ Trujet = 0
102
+
103
+ elif (airline=='Vistara'):
104
+ Jet_Airways = 0
105
+ IndiGo = 0
106
+ Air_India = 0
107
+ Multiple_carriers = 0
108
+ SpiceJet = 0
109
+ Vistara = 1
110
+ GoAir = 0
111
+ Multiple_carriers_Premium_economy = 0
112
+ Jet_Airways_Business = 0
113
+ Vistara_Premium_economy = 0
114
+ Trujet = 0
115
+
116
+ elif (airline=='GoAir'):
117
+ Jet_Airways = 0
118
+ IndiGo = 0
119
+ Air_India = 0
120
+ Multiple_carriers = 0
121
+ SpiceJet = 0
122
+ Vistara = 0
123
+ GoAir = 1
124
+ Multiple_carriers_Premium_economy = 0
125
+ Jet_Airways_Business = 0
126
+ Vistara_Premium_economy = 0
127
+ Trujet = 0
128
+
129
+ elif (airline=='Multiple carriers Premium economy'):
130
+ Jet_Airways = 0
131
+ IndiGo = 0
132
+ Air_India = 0
133
+ Multiple_carriers = 0
134
+ SpiceJet = 0
135
+ Vistara = 0
136
+ GoAir = 0
137
+ Multiple_carriers_Premium_economy = 1
138
+ Jet_Airways_Business = 0
139
+ Vistara_Premium_economy = 0
140
+ Trujet = 0
141
+
142
+ elif (airline=='Jet Airways Business'):
143
+ Jet_Airways = 0
144
+ IndiGo = 0
145
+ Air_India = 0
146
+ Multiple_carriers = 0
147
+ SpiceJet = 0
148
+ Vistara = 0
149
+ GoAir = 0
150
+ Multiple_carriers_Premium_economy = 0
151
+ Jet_Airways_Business = 1
152
+ Vistara_Premium_economy = 0
153
+ Trujet = 0
154
+
155
+ elif (airline=='Vistara Premium economy'):
156
+ Jet_Airways = 0
157
+ IndiGo = 0
158
+ Air_India = 0
159
+ Multiple_carriers = 0
160
+ SpiceJet = 0
161
+ Vistara = 0
162
+ GoAir = 0
163
+ Multiple_carriers_Premium_economy = 0
164
+ Jet_Airways_Business = 0
165
+ Vistara_Premium_economy = 1
166
+ Trujet = 0
167
+
168
+ elif (airline=='Trujet'):
169
+ Jet_Airways = 0
170
+ IndiGo = 0
171
+ Air_India = 0
172
+ Multiple_carriers = 0
173
+ SpiceJet = 0
174
+ Vistara = 0
175
+ GoAir = 0
176
+ Multiple_carriers_Premium_economy = 0
177
+ Jet_Airways_Business = 0
178
+ Vistara_Premium_economy = 0
179
+ Trujet = 1
180
+
181
+ else:
182
+ Jet_Airways = 0
183
+ IndiGo = 0
184
+ Air_India = 0
185
+ Multiple_carriers = 0
186
+ SpiceJet = 0
187
+ Vistara = 0
188
+ GoAir = 0
189
+ Multiple_carriers_Premium_economy = 0
190
+ Jet_Airways_Business = 0
191
+ Vistara_Premium_economy = 0
192
+ Trujet = 0
193
+
194
+ Source = request.form["Source"]
195
+ if (Source == 'Delhi'):
196
+ s_Delhi = 1
197
+ s_Kolkata = 0
198
+ s_Mumbai = 0
199
+ s_Chennai = 0
200
+
201
+ elif (Source == 'Kolkata'):
202
+ s_Delhi = 0
203
+ s_Kolkata = 1
204
+ s_Mumbai = 0
205
+ s_Chennai = 0
206
+
207
+ elif (Source == 'Mumbai'):
208
+ s_Delhi = 0
209
+ s_Kolkata = 0
210
+ s_Mumbai = 1
211
+ s_Chennai = 0
212
+
213
+ elif (Source == 'Chennai'):
214
+ s_Delhi = 0
215
+ s_Kolkata = 0
216
+ s_Mumbai = 0
217
+ s_Chennai = 1
218
+
219
+ else:
220
+ s_Delhi = 0
221
+ s_Kolkata = 0
222
+ s_Mumbai = 0
223
+ s_Chennai = 0
224
+
225
+
226
+ Destination = request.form["Destination"]
227
+ if (Destination == 'Cochin'):
228
+ d_Cochin = 1
229
+ d_Delhi = 0
230
+ d_Hyderabad = 0
231
+ d_Kolkata = 0
232
+
233
+ elif (Destination == 'Delhi'):
234
+ d_Cochin = 0
235
+ d_Delhi = 1
236
+ d_Hyderabad = 0
237
+ d_Kolkata = 0
238
+
239
+ elif (Destination == 'Hyderabad'):
240
+ d_Cochin = 0
241
+ d_Delhi = 0
242
+ d_Hyderabad = 1
243
+ d_Kolkata = 0
244
+
245
+ elif (Destination == 'Kolkata'):
246
+ d_Cochin = 0
247
+ d_Delhi = 0
248
+ d_Hyderabad = 0
249
+ d_Kolkata = 1
250
+
251
+ else:#Banglore
252
+ d_Cochin = 0
253
+ d_Delhi = 0
254
+ d_Hyderabad = 0
255
+ d_Kolkata = 0
256
+
257
+ output = model.predict([[Total_stops,
258
+ Journey_day,
259
+ Journey_month,
260
+ Departure_hour,
261
+ Departure_min,
262
+ Arrival_hour,
263
+ Arrival_min,
264
+ dur_hour,
265
+ dur_min,
266
+ Air_India,
267
+ GoAir,
268
+ IndiGo,
269
+ Jet_Airways,
270
+ Jet_Airways_Business,
271
+ Multiple_carriers,
272
+ Multiple_carriers_Premium_economy,
273
+ SpiceJet,
274
+ Trujet,
275
+ Vistara,
276
+ Vistara_Premium_economy,
277
+ s_Chennai,
278
+ s_Delhi,
279
+ s_Kolkata,
280
+ s_Mumbai,
281
+ d_Cochin,
282
+ d_Delhi,
283
+ d_Hyderabad,
284
+ d_Kolkata]])
285
+
286
+ output = round(output[0],2)
287
+ return render_template('home.html',predictions='You will have to Pay approx Rs. {}'.format(output))
288
+
289
+
290
+ if __name__ == '__main__':
291
+ app.run(debug=True)
flight_rf.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb54400ec7967f4bfe68fd5dafb5b63926f6d0e54e8a9d177592e975e0d83f16
3
+ size 479762327
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ openpyxl
2
+ seaborn
3
+ flask
4
+ pandas
5
+ Gunicorn
6
+ flask_cors
7
+ scikit-learn
8
+ matplotlib
9
+ numpy
10
+ datetime
11
+ uvicorn
templates/home.html ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html lang="en">
2
+ <style>
3
+ body {
4
+ background-image: url('/static/img/bg3.jpg');
5
+ background-repeat: no-repeat;
6
+ background-attachment: fixed;
7
+ background-size: cover;
8
+ }
9
+
10
+ img {
11
+ display: block;
12
+ margin-left: auto;
13
+ margin-right: auto;
14
+ align-self: center;
15
+ }
16
+
17
+ .navbar {
18
+ background-color: #333333;
19
+ }
20
+
21
+ a {
22
+ color: #f1f9f9;
23
+ }
24
+
25
+ a:hover {
26
+ color: #f0f0f0;
27
+ }
28
+
29
+ .card {
30
+ border-radius: 1rem;
31
+ background-color: hotpink;
32
+ }
33
+ </style>
34
+
35
+
36
+
37
+ <head>
38
+ <meta charset="UTF-8">
39
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
40
+ <title>Flight Price Prediction</title>
41
+
42
+
43
+ <!-- BootStrap -->
44
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
45
+ integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
46
+
47
+
48
+ </head>
49
+
50
+ <body>
51
+
52
+ <nav class="navbar navbar-inverse navbar-fixed-top">
53
+ <div class="container-fluid">
54
+ <div class="navbar-header">
55
+ <a class="navbar-brand" href="/" style='color: #e1f4f3;'>FLIGHT PRICE</a>
56
+ </div>
57
+ </div>
58
+ </nav>
59
+
60
+ <div class="container my-5">
61
+ <form action="\predict" method="post">
62
+
63
+ <div class="row my-3">
64
+
65
+ <div class="col-sm-6">
66
+ <div class="card" style='border-radius: 2.15rem;opacity: 0.7;'>
67
+ <div class="card-body">
68
+ <h5 class="card-title">Departure Date</h5>
69
+ <input type="datetime-local" name="Dep_Time" id="Dep_Time" required="required">
70
+ </div>
71
+ </div>
72
+ </div>
73
+
74
+
75
+ <div class="col-sm-6">
76
+ <div class="card" style='border-radius: 2.15rem;opacity: 0.7;'>
77
+ <div class="card-body">
78
+ <h5 class="card-title">Arrival Date</h5>
79
+ <input type="datetime-local" name="Arrival_Time" id="Arrival_Time" required="required">
80
+ </div>
81
+ </div>
82
+ </div>
83
+ </div>
84
+
85
+
86
+
87
+ <div class="row my-3">
88
+
89
+ <div class="col-sm-6">
90
+ <div class="card" style='border-radius: 2.15rem;opacity: 0.7;'>
91
+ <div class="card-body">
92
+ <h5 class="card-title">Source</h5>
93
+ <select name="Source" id="Source" required="required">
94
+ <option value="Delhi">Delhi</option>
95
+ <option value="Kolkata">Kolkata</option>
96
+ <option value="Banglore">Banglore</option>
97
+ <option value="Mumbai">Mumbai</option>
98
+ <option value="Chennai">Chennai</option>
99
+ </select>
100
+ </div>
101
+ </div>
102
+ </div>
103
+
104
+ <div class="col-sm-6">
105
+ <div class="card" style='border-radius: 2.15rem;opacity: 0.7;'>
106
+ <div class="card-body">
107
+ <h5 class="card-title">Destination</h5>
108
+ <select name="Destination" id="Destination" required="required">
109
+ <option value="Cochin">Cochin</option>
110
+ <option value="Delhi">Delhi</option>
111
+ <option value="Banglore">Banglore</option>
112
+ <option value="Hyderabad">Hyderabad</option>
113
+ <option value="Kolkata">Kolkata</option>
114
+ </select>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </div>
119
+
120
+
121
+ <div class="row my-3">
122
+
123
+ <div class="col-sm-6">
124
+ <div class="card" style='border-radius: 2.15rem;opacity: 0.7;'>
125
+ <div class="card-body">
126
+ <h5 class="card-title">Stopage</h5>
127
+ <select name="stops" required="required">
128
+ <option value="0">Non-Stop</option>
129
+ <option value="1">1</option>
130
+ <option value="2">2</option>
131
+ <option value="3">3</option>
132
+ <option value="4">4</option>
133
+ </select>
134
+ </div>
135
+ </div>
136
+ </div>
137
+
138
+ <div class="col-sm-6">
139
+ <div class="card" style='border-radius: 2.15rem;opacity: 0.7;'>
140
+ <div class="card-body">
141
+ <h5 class="card-title">Which Airline you want to travel?</h5>
142
+ <select name="airline" id="airline" required="required">
143
+ <option value="Jet Airways">Jet Airways</option>
144
+ <option value="IndiGo">IndiGo</option>
145
+ <option value="Air India">Air India</option>
146
+ <option value="Multiple carriers">Multiple carriers</option>
147
+ <option value="SpiceJet">SpiceJet</option>
148
+ <option value="Vistara">Vistara</option>
149
+ <option value="Air Asia">Air Asia</option>
150
+ <option value="GoAir">GoAir</option>
151
+ <option value="Multiple carriers Premium economy">Multiple carriers Premium economy
152
+ </option>
153
+ <option value="Jet Airways Business">Jet Airways Business</option>
154
+ <option value="Vistara Premium economy">Vistara Premium economy</option>
155
+ <option value="Trujet">Trujet</option>
156
+ </select>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ </div>
161
+
162
+
163
+
164
+
165
+ <div style='text-align:center'>
166
+ <button type="submit" value='Submit' class="btn btn-primary px-5" style="font-size: 25px;">Submit</button>
167
+ </div>
168
+ </form>
169
+
170
+ <h1 style='text-align: center;color: ivory;'><b>{{ predictions }}</b></h1>
171
+
172
+
173
+
174
+ </div>
175
+
176
+
177
+
178
+
179
+ <!-- JavaScript -->
180
+ <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
181
+ integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
182
+ crossorigin="anonymous"></script>
183
+ <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
184
+ integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
185
+ crossorigin="anonymous"></script>
186
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
187
+ integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
188
+ crossorigin="anonymous"></script>
189
+
190
+ </body>
191
+
192
+ </html>