abdulrafishaik commited on
Commit
8e59fb3
·
verified ·
1 Parent(s): 204b6f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py CHANGED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle #pickle: Loads the saved model (Model.pickle).
2
+ import pandas as pd
3
+ import numpy as np
4
+ import gradio as gr # gradio: Creates a web interface for user input and model predictions.
5
+
6
+
7
+ with open("Model.pickle","rb") as f:
8
+
9
+ model=pickle.load(f) #Opens the Model.pickle file in read-binary (rb) mode.
10
+
11
+ def predict_booking(num_passengers, sales_channel, trip_type, purchase_lead, length_of_stay,
12
+ flight_hour, flight_day, route, booking_origin, wants_extra_baggage,
13
+ wants_preferred_seat, wants_in_flight_meals, flight_duration):
14
+
15
+ input_data=np.array([[num_passengers, sales_channel, trip_type, purchase_lead, length_of_stay,
16
+ flight_hour, flight_day, route, booking_origin, wants_extra_baggage,
17
+ wants_preferred_seat, wants_in_flight_meals, flight_duration]])
18
+
19
+ prediction=model.predict(input_data)[0]
20
+
21
+ return "Booking Completed" if prediction == 1 else "Booking Not Completed"
22
+
23
+
24
+ routes = ["AKLDEL", "AKLHGH", "AKLHND", "AKLICN", "AKLKIX", "AKLKTM"]
25
+
26
+
27
+ iface = gr.Interface(
28
+ fn=predict_booking
29
+ inputs=[gr.Number(label="Number of Passengers"),
30
+ gr.Dropdown(choices=["Online","Offline"],label="Sales Channel"),
31
+ gr.Dropdown(choices=["Single Trip","Round Trip"],label="Trip Type"),
32
+ gr.Number(label="Purchase Lead"),
33
+ gr.Number(label="Length of Stay"),
34
+ gr.Number(label="Flight Hours"),
35
+ gr.Number(label="Flight Day"),
36
+ gr.Number(choices=routes,label="Route"),
37
+ gr.Dropdown(choices=["Yes","No"],label="Want Extra Baggage"),
38
+ gr.Dropdown(choices=["Yes","No"],label="Want Prefered Seat"),
39
+ gr.Dropdown(choices=["Yes","No"],label="Want In-Flight Meals"),
40
+ gr.Number(label="Flight Duration")],
41
+ outputs=gr.Textbox(label="Bookig Prediction"),
42
+ title="British Airways Booking Predictions",
43
+ Description="Enter Flight Details to Predict Booking Completion"
44
+
45
+ )
46
+ iface.launch()