import streamlit as st import requests # Configuration de la page st.set_page_config( page_title="Getaround Price Predictor", page_icon="🚗", layout="centered" ) # Titre st.title("🚗 Getaround Price Predictor") st.markdown( "Estimez le prix de location journalier d'un véhicule à l'aide d'un modèle de Machine Learning." ) st.divider() # Formulaire model_key = st.selectbox( "Marque du véhicule", [ "Citroën", "Peugeot", "PGO", "Renault", "Audi", "BMW", "Ford", "Mercedes", "Opel", "Porsche", "Volkswagen", "KIA Motors", "Alfa Romeo", "Ferrari", "Fiat", "Lamborghini", "Maserati", "Lexus", "Honda", "Mazda", "Mini", "Mitsubishi", "Nissan", "SEAT", "Subaru", "Suzuki", "Toyota", "Yamaha" ] ) mileage = st.number_input( "Kilométrage", min_value=0, value=50000, step=1000 ) engine_power = st.number_input( "Puissance moteur", min_value=0, value=120 ) fuel = st.selectbox( "Carburant", ["diesel", "petrol", "hybrid_petrol", "electro"] ) paint_color = st.selectbox( "Couleur", [ "black", "grey", "white", "red", "silver", "blue", "orange", "beige", "brown", "green" ] ) car_type = st.selectbox( "Type de véhicule", [ "convertible", "coupe", "estate", "hatchback", "sedan", "subcompact", "suv", "van" ] ) st.subheader("Options") private_parking_available = st.checkbox("Private Parking") has_gps = st.checkbox("GPS") has_air_conditioning = st.checkbox("Air Conditioning") automatic_car = st.checkbox("Automatic Transmission") has_getaround_connect = st.checkbox("Getaround Connect") has_speed_regulator = st.checkbox("Speed Regulator") winter_tires = st.checkbox("Winter Tires") # Bouton prédiction if st.button("Predict Price"): payload = { "model_key": model_key, "mileage": mileage, "engine_power": engine_power, "fuel": fuel, "paint_color": paint_color, "car_type": car_type, "private_parking_available": private_parking_available, "has_gps": has_gps, "has_air_conditioning": has_air_conditioning, "automatic_car": automatic_car, "has_getaround_connect": has_getaround_connect, "has_speed_regulator": has_speed_regulator, "winter_tires": winter_tires } try: response = requests.post( "https://wissamh-getaround-api.hf.space/predict", json=payload, timeout=30 ) if response.status_code == 200: result = response.json() prediction = result["prix_location_par_jour"] st.success( f"Prix estimé : {prediction:.2f} € / jour" ) else: st.error( f"Erreur API : {response.status_code}" ) st.write(response.text) except Exception as e: st.error( f"Connection error : {e}" )