Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- RF_model.joblib +3 -0
- app.py +106 -0
RF_model.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b281e50fea47fdf98bca4232d4a90bb5f57b94fc33c9db869d45b6957c1bd969
|
| 3 |
+
size 45133345
|
app.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from joblib import dump, load
|
| 4 |
+
|
| 5 |
+
# model
|
| 6 |
+
Model= load('RF_model.joblib')
|
| 7 |
+
|
| 8 |
+
# predict
|
| 9 |
+
def predict_note_authentication(values):
|
| 10 |
+
ans=Model.predict([values])
|
| 11 |
+
return ans
|
| 12 |
+
def main():
|
| 13 |
+
# st.title("Flight Fair Predictions")
|
| 14 |
+
html_temp = """
|
| 15 |
+
<div style="background-color:tomato;padding:10px">
|
| 16 |
+
<h2 style="color:white;text-align:center;">Streamlit Flight Fair Predictions ML App </h2>
|
| 17 |
+
</div>
|
| 18 |
+
"""
|
| 19 |
+
st.markdown(html_temp, unsafe_allow_html=True)
|
| 20 |
+
|
| 21 |
+
# Airline selection
|
| 22 |
+
Airline_options = ['Jet Airways', 'IndiGo', 'Air India', 'Multiple carriers',
|
| 23 |
+
'SpiceJet', 'Vistara', 'Air Asia', 'GoAir',
|
| 24 |
+
'Multiple carriers Premium economy', 'Jet Airways Business',
|
| 25 |
+
'Vistara Premium economy', 'Trujet']
|
| 26 |
+
Airline = st.selectbox('Airline', options=Airline_options)
|
| 27 |
+
Airline_dict = {'Jet Airways': 3849, 'IndiGo': 2053, 'Air India': 1751,
|
| 28 |
+
'Multiple carriers': 1196, 'SpiceJet': 818, 'Vistara': 479,
|
| 29 |
+
'Air Asia': 319, 'GoAir': 194, 'Multiple carriers Premium economy': 13,
|
| 30 |
+
'Jet Airways Business': 6, 'Vistara Premium economy': 3, 'Trujet': 1}
|
| 31 |
+
Airline_value = Airline_dict.get(Airline, 0) # default to 0 if not found
|
| 32 |
+
|
| 33 |
+
# Total Stops selection
|
| 34 |
+
Total_Stops_options = ['non-stop', '1 stop', '2 stops', '3 stops', '4 stops']
|
| 35 |
+
Total_Stops = st.selectbox('Total Stops', options=Total_Stops_options)
|
| 36 |
+
Total_Stops_dict = {'non-stop': 0, '1 stop': 1, '2 stops': 2, '3 stops': 3, '4 stops': 4}
|
| 37 |
+
Total_Stops_value = Total_Stops_dict.get(Total_Stops, 0) # default to 0 if not found
|
| 38 |
+
|
| 39 |
+
# Date_of_Journey
|
| 40 |
+
Date_of_Journey=st.date_input('Date_of_Journey')
|
| 41 |
+
Day_of_Journey=pd.to_datetime(Date_of_Journey).day
|
| 42 |
+
Month_of_Journey=pd.to_datetime(Date_of_Journey).month
|
| 43 |
+
|
| 44 |
+
# Dep_Time
|
| 45 |
+
Dep_Time=st.text_input("Dep_Time (HH:MM)", "00:00")
|
| 46 |
+
# Convert Dep_Time to string in the format "HH:MM"
|
| 47 |
+
time_dep = pd.to_datetime(Dep_Time, format='mixed')
|
| 48 |
+
Dep_hour=time_dep.hour
|
| 49 |
+
Dep_min=time_dep.minute
|
| 50 |
+
|
| 51 |
+
# Arrival_Time
|
| 52 |
+
Arrival_Time=st.text_input("Arrival Time (HH:MM)", "13:30")
|
| 53 |
+
time_arr = pd.to_datetime(Arrival_Time, format='mixed')
|
| 54 |
+
Arrival_hour=time_arr.hour
|
| 55 |
+
Arrival_min=time_arr.minute
|
| 56 |
+
|
| 57 |
+
# Duration
|
| 58 |
+
departure_hour, departure_minute = map(int, Dep_Time.split(':'))
|
| 59 |
+
arrival_hour, arrival_minute = map(int, Arrival_Time.split(':'))
|
| 60 |
+
Duration_hour = arrival_hour - departure_hour # Calculate the duration
|
| 61 |
+
Duration_minute = arrival_minute - departure_minute
|
| 62 |
+
|
| 63 |
+
if Duration_minute < 0:
|
| 64 |
+
Duration_hour -= 1
|
| 65 |
+
Duration_minute += 60
|
| 66 |
+
|
| 67 |
+
Duration_in_min = Duration_hour*60 + Duration_minute
|
| 68 |
+
|
| 69 |
+
# In-flight meal not included
|
| 70 |
+
In_flight_meal_not_included=st.selectbox('In-flight meal not included',options=['yes','no'])
|
| 71 |
+
if In_flight_meal_not_included=='yes':
|
| 72 |
+
In_flight_meal_not_included=1
|
| 73 |
+
else:
|
| 74 |
+
In_flight_meal_not_included=0
|
| 75 |
+
|
| 76 |
+
# No check-in baggage included
|
| 77 |
+
No_check_in_baggage_included=st.selectbox('No check-in baggage included',options=['yes','no'])
|
| 78 |
+
if No_check_in_baggage_included=='yes':
|
| 79 |
+
No_check_in_baggage_included=1
|
| 80 |
+
else:
|
| 81 |
+
No_check_in_baggage_included=0
|
| 82 |
+
|
| 83 |
+
# Source
|
| 84 |
+
Source=st.selectbox('Source',options=['Banglore','Chennai','Delhi','Kolkata','Mumbai'])
|
| 85 |
+
source_index = ['Banglore', 'Chennai', 'Delhi', 'Kolkata', 'Mumbai']
|
| 86 |
+
source_value = [1 if src == Source else 0 for src in source_index]
|
| 87 |
+
|
| 88 |
+
# Destination
|
| 89 |
+
Destination=st.selectbox('Destination',options=['Banglore',
|
| 90 |
+
'Cochin',
|
| 91 |
+
'Delhi',
|
| 92 |
+
'Hyderabad',
|
| 93 |
+
'Kolkata'])
|
| 94 |
+
destination_index = ['Banglore', 'Cochin', 'Delhi', 'Hyderabad', 'Kolkata']
|
| 95 |
+
destination_value = [1 if dest == Destination else 0 for dest in destination_index]
|
| 96 |
+
|
| 97 |
+
values=[Airline_value, Total_Stops_value, Day_of_Journey, Month_of_Journey,
|
| 98 |
+
Dep_hour, Dep_min, Arrival_hour, Arrival_min, Duration_in_min,
|
| 99 |
+
In_flight_meal_not_included, No_check_in_baggage_included]+source_value+destination_value
|
| 100 |
+
|
| 101 |
+
if st.button("Predict"):
|
| 102 |
+
result=predict_note_authentication(values)
|
| 103 |
+
st.success(f'Expected Flight price is : {result}')
|
| 104 |
+
|
| 105 |
+
if __name__ == "__main__":
|
| 106 |
+
main()
|