viruthik commited on
Commit
6048926
·
1 Parent(s): ab10117

Upload 16 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ ss.png filter=lfs diff=lfs merge=lfs -text
37
+ static/img/bg7.jpg filter=lfs diff=lfs merge=lfs -text
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
 
README.md CHANGED
@@ -1,12 +1,12 @@
1
- ---
2
- title: Flight
3
- emoji: 📉
4
- colorFrom: indigo
5
- colorTo: purple
6
- sdk: streamlit
7
- sdk_version: 1.28.2
8
- app_file: app.py
9
- pinned: false
10
- ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
1
+ # Flight-Price-Prediction
 
 
 
 
 
 
 
 
 
2
 
3
+ - I did this project just to perform some next level feature engineerings to elevate the performane of this model.
4
+ - I have also created a gui using HTML,Bootstrap,CSS and implemnted the backend in Flask for this project and will be uploading that on Heroku soon.
5
+ - Actually this was a Kaggle problem.
6
+ - Initially I used RandomForestRegressor but that was not giving very satisfying results so I used RandomSearchCV to find best hyerparameters and came up witha a good model with r2 score of around 0.82.
7
+ - Also used ExtraTreeRegressor to visualize the importances of all the features.
8
+ - Just run app.py to see the gui on local host.
9
+
10
+ Do visit my blog for better explanations: https://machinelearningprojects.net/flight-price-prediction/
11
+
12
+ ![](ss.png)
__pycache__/app.cpython-311.pyc ADDED
Binary file (5.66 kB). View file
 
app.py ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ model = pickle.load(open('flight_rf.pkl','rb'))
7
+
8
+ app = Flask(__name__)
9
+
10
+ @app.route('/')
11
+ @cross_origin()
12
+ def home():
13
+ return render_template('home.html')
14
+
15
+ @app.route('/predict',methods=['GET','POST'])
16
+ @cross_origin()
17
+ def predict():
18
+ if request.method=='POST':
19
+ dep_time = request.form['Dep_Time']
20
+
21
+ Journey_day = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").day
22
+ Journey_month = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").month
23
+
24
+ Departure_hour = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").hour
25
+ Departure_min = pd.to_datetime(dep_time,format="%Y-%m-%dT%H:%M").minute
26
+
27
+ arrival_time = request.form['Arrival_Time']
28
+ Arrival_hour = pd.to_datetime(arrival_time,format="%Y-%m-%dT%H:%M").hour
29
+ Arrival_min = pd.to_datetime(arrival_time,format="%Y-%m-%dT%H:%M").minute
30
+
31
+ Total_stops = int(request.form['stops'])
32
+
33
+ dur_hour = abs(Arrival_hour-Departure_hour)
34
+ dur_min = abs(Arrival_min-Departure_min)
35
+
36
+ airline=request.form['airline']
37
+ if(airline=='Jet Airways'):
38
+ Jet_Airways = 1
39
+ IndiGo = 0
40
+ Air_India = 0
41
+ Multiple_carriers = 0
42
+ SpiceJet = 0
43
+ Vistara = 0
44
+ GoAir = 0
45
+ Multiple_carriers_Premium_economy = 0
46
+ Jet_Airways_Business = 0
47
+ Vistara_Premium_economy = 0
48
+ Trujet = 0
49
+
50
+ elif (airline=='IndiGo'):
51
+ Jet_Airways = 0
52
+ IndiGo = 1
53
+ Air_India = 0
54
+ Multiple_carriers = 0
55
+ SpiceJet = 0
56
+ Vistara = 0
57
+ GoAir = 0
58
+ Multiple_carriers_Premium_economy = 0
59
+ Jet_Airways_Business = 0
60
+ Vistara_Premium_economy = 0
61
+ Trujet = 0
62
+
63
+ elif (airline=='Air India'):
64
+ Jet_Airways = 0
65
+ IndiGo = 0
66
+ Air_India = 1
67
+ Multiple_carriers = 0
68
+ SpiceJet = 0
69
+ Vistara = 0
70
+ GoAir = 0
71
+ Multiple_carriers_Premium_economy = 0
72
+ Jet_Airways_Business = 0
73
+ Vistara_Premium_economy = 0
74
+ Trujet = 0
75
+
76
+ elif (airline=='Multiple carriers'):
77
+ Jet_Airways = 0
78
+ IndiGo = 0
79
+ Air_India = 0
80
+ Multiple_carriers = 1
81
+ SpiceJet = 0
82
+ Vistara = 0
83
+ GoAir = 0
84
+ Multiple_carriers_Premium_economy = 0
85
+ Jet_Airways_Business = 0
86
+ Vistara_Premium_economy = 0
87
+ Trujet = 0
88
+
89
+ elif (airline=='SpiceJet'):
90
+ Jet_Airways = 0
91
+ IndiGo = 0
92
+ Air_India = 0
93
+ Multiple_carriers = 0
94
+ SpiceJet = 1
95
+ Vistara = 0
96
+ GoAir = 0
97
+ Multiple_carriers_Premium_economy = 0
98
+ Jet_Airways_Business = 0
99
+ Vistara_Premium_economy = 0
100
+ Trujet = 0
101
+
102
+ elif (airline=='Vistara'):
103
+ Jet_Airways = 0
104
+ IndiGo = 0
105
+ Air_India = 0
106
+ Multiple_carriers = 0
107
+ SpiceJet = 0
108
+ Vistara = 1
109
+ GoAir = 0
110
+ Multiple_carriers_Premium_economy = 0
111
+ Jet_Airways_Business = 0
112
+ Vistara_Premium_economy = 0
113
+ Trujet = 0
114
+
115
+ elif (airline=='GoAir'):
116
+ Jet_Airways = 0
117
+ IndiGo = 0
118
+ Air_India = 0
119
+ Multiple_carriers = 0
120
+ SpiceJet = 0
121
+ Vistara = 0
122
+ GoAir = 1
123
+ Multiple_carriers_Premium_economy = 0
124
+ Jet_Airways_Business = 0
125
+ Vistara_Premium_economy = 0
126
+ Trujet = 0
127
+
128
+ elif (airline=='Multiple carriers Premium economy'):
129
+ Jet_Airways = 0
130
+ IndiGo = 0
131
+ Air_India = 0
132
+ Multiple_carriers = 0
133
+ SpiceJet = 0
134
+ Vistara = 0
135
+ GoAir = 0
136
+ Multiple_carriers_Premium_economy = 1
137
+ Jet_Airways_Business = 0
138
+ Vistara_Premium_economy = 0
139
+ Trujet = 0
140
+
141
+ elif (airline=='Jet Airways Business'):
142
+ Jet_Airways = 0
143
+ IndiGo = 0
144
+ Air_India = 0
145
+ Multiple_carriers = 0
146
+ SpiceJet = 0
147
+ Vistara = 0
148
+ GoAir = 0
149
+ Multiple_carriers_Premium_economy = 0
150
+ Jet_Airways_Business = 1
151
+ Vistara_Premium_economy = 0
152
+ Trujet = 0
153
+
154
+ elif (airline=='Vistara Premium economy'):
155
+ Jet_Airways = 0
156
+ IndiGo = 0
157
+ Air_India = 0
158
+ Multiple_carriers = 0
159
+ SpiceJet = 0
160
+ Vistara = 0
161
+ GoAir = 0
162
+ Multiple_carriers_Premium_economy = 0
163
+ Jet_Airways_Business = 0
164
+ Vistara_Premium_economy = 1
165
+ Trujet = 0
166
+
167
+ elif (airline=='Trujet'):
168
+ Jet_Airways = 0
169
+ IndiGo = 0
170
+ Air_India = 0
171
+ Multiple_carriers = 0
172
+ SpiceJet = 0
173
+ Vistara = 0
174
+ GoAir = 0
175
+ Multiple_carriers_Premium_economy = 0
176
+ Jet_Airways_Business = 0
177
+ Vistara_Premium_economy = 0
178
+ Trujet = 1
179
+
180
+ else:
181
+ Jet_Airways = 0
182
+ IndiGo = 0
183
+ Air_India = 0
184
+ Multiple_carriers = 0
185
+ SpiceJet = 0
186
+ Vistara = 0
187
+ GoAir = 0
188
+ Multiple_carriers_Premium_economy = 0
189
+ Jet_Airways_Business = 0
190
+ Vistara_Premium_economy = 0
191
+ Trujet = 0
192
+
193
+ Source = request.form["Source"]
194
+ if (Source == 'Delhi'):
195
+ s_Delhi = 1
196
+ s_Kolkata = 0
197
+ s_Mumbai = 0
198
+ s_Chennai = 0
199
+
200
+ elif (Source == 'Kolkata'):
201
+ s_Delhi = 0
202
+ s_Kolkata = 1
203
+ s_Mumbai = 0
204
+ s_Chennai = 0
205
+
206
+ elif (Source == 'Mumbai'):
207
+ s_Delhi = 0
208
+ s_Kolkata = 0
209
+ s_Mumbai = 1
210
+ s_Chennai = 0
211
+
212
+ elif (Source == 'Chennai'):
213
+ s_Delhi = 0
214
+ s_Kolkata = 0
215
+ s_Mumbai = 0
216
+ s_Chennai = 1
217
+
218
+ else:
219
+ s_Delhi = 0
220
+ s_Kolkata = 0
221
+ s_Mumbai = 0
222
+ s_Chennai = 0
223
+
224
+
225
+ Destination = request.form["Destination"]
226
+ if (Destination == 'Cochin'):
227
+ d_Cochin = 1
228
+ d_Delhi = 0
229
+ d_Hyderabad = 0
230
+ d_Kolkata = 0
231
+
232
+ elif (Destination == 'Delhi'):
233
+ d_Cochin = 0
234
+ d_Delhi = 1
235
+ d_Hyderabad = 0
236
+ d_Kolkata = 0
237
+
238
+ elif (Destination == 'Hyderabad'):
239
+ d_Cochin = 0
240
+ d_Delhi = 0
241
+ d_Hyderabad = 1
242
+ d_Kolkata = 0
243
+
244
+ elif (Destination == 'Kolkata'):
245
+ d_Cochin = 0
246
+ d_Delhi = 0
247
+ d_Hyderabad = 0
248
+ d_Kolkata = 1
249
+
250
+ else:#Banglore
251
+ d_Cochin = 0
252
+ d_Delhi = 0
253
+ d_Hyderabad = 0
254
+ d_Kolkata = 0
255
+
256
+ output = model.predict([[Total_stops,
257
+ Journey_day,
258
+ Journey_month,
259
+ Departure_hour,
260
+ Departure_min,
261
+ Arrival_hour,
262
+ Arrival_min,
263
+ dur_hour,
264
+ dur_min,
265
+ Air_India,
266
+ GoAir,
267
+ IndiGo,
268
+ Jet_Airways,
269
+ Jet_Airways_Business,
270
+ Multiple_carriers,
271
+ Multiple_carriers_Premium_economy,
272
+ SpiceJet,
273
+ Trujet,
274
+ Vistara,
275
+ Vistara_Premium_economy,
276
+ s_Chennai,
277
+ s_Delhi,
278
+ s_Kolkata,
279
+ s_Mumbai,
280
+ d_Cochin,
281
+ d_Delhi,
282
+ d_Hyderabad,
283
+ d_Kolkata]])
284
+
285
+ output = round(output[0],2)
286
+ return render_template('home.html',predictions='You will have to Pay approx Rs. {}'.format(output))
287
+
288
+
289
+ if __name__ == '__main__':
290
+ app.run(debug=True)
flight price.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
flight_rf.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd7f420d1eb2cc1a20da7ea6294c0a145782721bdac9c96cce9140e6a82f2974
3
+ size 479386591
ss.png ADDED

Git LFS Details

  • SHA256: 5bba41a971ac3a3d48849a19bac83a4eb5afae70a4ecb34b20c1820ddc002ddc
  • Pointer size: 132 Bytes
  • Size of remote file: 1.25 MB
static/img/bg.jpg ADDED
static/img/bg3.jpg ADDED
static/img/bg4.jpg ADDED
static/img/bg5.jpg ADDED
static/img/bg6.jpg ADDED
static/img/bg7.jpg ADDED

Git LFS Details

  • SHA256: a5a5e0731782c6ca56a217ee95c3271c9a34737b8578a42cacf14402de7cf4e1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.54 MB
templates/home.html ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html lang="en">
2
+ <style>
3
+ body {
4
+ background-image: url('/static/img/bg7.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
+ <footer class='text-light bg-dark position-fixed fixed-bottom '>
174
+ <p class='text-center py my-0'>
175
+ Made with ❤ by Abhishek Sharma
176
+ </p>
177
+ </footer>
178
+ </div>
179
+
180
+
181
+
182
+
183
+ <!-- JavaScript -->
184
+ <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
185
+ integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
186
+ crossorigin="anonymous"></script>
187
+ <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
188
+ integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
189
+ crossorigin="anonymous"></script>
190
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
191
+ integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
192
+ crossorigin="anonymous"></script>
193
+
194
+ </body>
195
+
196
+ </html>