Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pickle | |
| import pandas as pd | |
| # Load trained pipeline | |
| with open("uber_fare_amount.pkl", "rb") as model_file: | |
| model = pickle.load(model_file) | |
| # Streamlit UI | |
| st.title("🚖 Uber Fare Prediction") | |
| st.markdown("Enter trip details to predict the fare.") | |
| # User inputs | |
| pickup_lat = st.number_input("Pickup Latitude") | |
| pickup_long = st.number_input("Pickup Longitude") | |
| dropoff_lat = st.number_input("Dropoff Latitude") | |
| dropoff_long = st.number_input("Dropoff Longitude") | |
| passenger_count = st.number_input("Passenger Count", min_value=1, max_value=6, step=1) | |
| # pickup_datetime = st.text_input("Pickup Date & Time (YYYY-MM-DD HH:MM:SS)") | |
| # Prediction | |
| if st.button("Predict Fare"): | |
| # Prepare input as a DataFrame with correct column names | |
| input_data = pd.DataFrame([{ | |
| 'pickup_latitude': pickup_lat, | |
| 'pickup_longitude': pickup_long, | |
| 'dropoff_latitude': dropoff_lat, | |
| 'dropoff_longitude': dropoff_long, | |
| 'passenger_count': passenger_count, | |
| }]) | |
| # if st.button("Predict Fare"): | |
| # # Prepare input as a DataFrame with correct column names | |
| # input_data = pd.DataFrame([{ | |
| # 'pickup_latitude': pickup_lat, | |
| # 'pickup_longitude': pickup_long, | |
| # 'dropoff_latitude': dropoff_lat, | |
| # 'dropoff_longitude': dropoff_long, | |
| # 'passenger_count': passenger_count, | |
| # 'pickup_datetime': pickup_datetime | |
| # }]) | |
| predicted_fare = model.predict(input_data)[0] | |
| st.success(f"Estimated Fare: ${predicted_fare:.2f}") | |