Spaces:
Configuration error
Configuration error
| import streamlit as st | |
| import pandas as pd | |
| import pickle | |
| def app(): | |
| st.header('Model Prediction') | |
| st.write(""" | |
| Created by Maria Melisa Gunawan | |
| Airline Passenger Satisfaction Prediction | |
| """) | |
| def fetch_data(): | |
| # Ganti path file CSV sesuai dengan lokasi file Anda | |
| df = pd.read_csv('airline_passenger_satisfaction.csv') | |
| return df | |
| df = fetch_data() | |
| st.header('User Input Features') | |
| def user_input(): | |
| online_boarding = st.slider("Online Boarding", 0, 5, 3) | |
| type_of_travel = st.slider("Type of Travel", 0, 1) | |
| inflight_entertainment = st.slider("Inflight Entertainment", 0, 5, 3) | |
| customer_class = st.slider("Customer Class", 0, 1, 2) | |
| seat_comfort = st.slider("Seat Comfort", 0, 5, 3) | |
| onboard_service = st.slider("Onboard Service", 0, 5, 3) | |
| leg_room_service = st.slider("Leg Room Service", 0, 5, 3) | |
| cleanliness = st.slider("Cleanliness", 0, 5, 3) | |
| inflight_wifi_service = st.slider("Inflight Wifi Service", 0, 5, 3) | |
| baggage_handling = st.slider("Baggage Handling", 0, 5, 3) | |
| inflight_service = st.slider("Inflight Service", 0, 5, 3) | |
| flight_distance = st.number_input("Flight Distance", min_value=0) | |
| checkin_service = st.slider("Checkin Service", 0, 5, 3) | |
| data = { | |
| 'online_boarding': [online_boarding], | |
| 'type_of_travel': [type_of_travel], | |
| 'inflight_entertainment': [inflight_entertainment], | |
| 'customer_class' : [customer_class], | |
| 'seat_comfort': [seat_comfort], | |
| 'onboard_service': [onboard_service], | |
| 'leg_room_service': [leg_room_service], | |
| 'cleanliness': [cleanliness], | |
| 'inflight_wifi_service': [inflight_wifi_service], | |
| 'baggage_handling': [baggage_handling], | |
| 'inflight_service': [inflight_service], | |
| 'flight_distance': [flight_distance], | |
| 'checkin_service': [checkin_service] | |
| } | |
| features = pd.DataFrame(data) | |
| return features | |
| input_df = user_input() | |
| st.subheader('User Input') | |
| st.write(input_df) | |
| # Load trained model | |
| filename = 'best_model.pkl' | |
| loaded_model = pickle.load(open(filename, 'rb')) | |
| # Predict | |
| prediction = loaded_model.predict(input_df) | |
| if prediction == 1: | |
| result = 'Satisfied' | |
| else: | |
| result = 'Dissatisfied' | |
| st.write('Predicted Passenger Satisfaction:') | |
| st.write(result) | |
| if __name__ == '__main__': | |
| app() | |