import gradio as gr import joblib import numpy as np # Charger le modèle en spécifiant le chemin absolu model_path = "./linear_regression_model.joblib" lr = joblib.load(model_path) # Fonction de prédiction def predict_price(*features): features = np.array(features).reshape(1, -1) prediction = lr.predict(features)[0] return round(prediction, 2) # Interface Gradio input_labels = ["Kms_Driven", "Present_Price", "Fuel_Type", "Seller_Type", "Transmission", "Age", "Selling_Price"] inputs = [gr.Number(label=label) for label in input_labels] output = gr.Number(label="Predicted Price") interface = gr.Interface(fn=predict_price, inputs=inputs, outputs=output, title="Car Price Prediction") # Lancer l'application if __name__ == "__main__": interface.launch()