modifschool

This commit is contained in:
Ladebeze66 2025-03-05 16:39:37 +01:00
parent a9b71d150a
commit a5616622a3
3 changed files with 14 additions and 38 deletions

View File

@ -5,7 +5,7 @@ import os
sys.path.append(os.path.abspath("src"))
from src.training_model import train_model
from src.gui import show_gui # Import propre et structuré
from src.gui import cli_interface # Nouvelle importation
def main():
print("Bienvenue dans le modèle de prédiction de prix de voiture !")
@ -17,7 +17,7 @@ def main():
from src.prediction import predict_price
# Lancer l'interface graphique après l'entraînement
print("Lancement de l'interface graphique...")
show_gui(predict_price)
cli_interface(predict_price)
if __name__ == "__main__":
main()

View File

@ -1,5 +1,4 @@
numpy
pandas
matplotlib
seaborn
tk
seaborn

View File

@ -1,36 +1,13 @@
import tkinter as tk
from tkinter import messagebox
def show_gui(predict_price):
"""Affiche l'interface graphique Tkinter pour entrer un kilométrage et voir le prix estimé."""
def estimate_price():
def cli_interface(predict_price):
"""Interface en ligne de commande pour entrer un kilométrage et voir le prix estimé."""
while True:
user_input = input("Entrez un kilométrage (ou 'q' pour quitter) : ")
if user_input.lower() == 'q':
print("Fermeture du programme.")
break
try:
km = float(entry_km.get()) # Récupère la valeur entrée
price = predict_price(km) # Prédiction du prix
label_result.config(text=f"Prix estimé : {price:.2f}", fg="green") # Affiche le prix
km = float(user_input)
price = predict_price(km)
print(f"Prix estimé : {price:.2f}")
except ValueError:
messagebox.showerror("Erreur", "Veuillez entrer un kilométrage valide.")
root = tk.Tk()
root.title("Estimation de prix de voiture")
frame = tk.Frame(root, padx=20, pady=20)
frame.pack()
label_title = tk.Label(frame, text="Estimation de prix de voiture", font=("Arial", 14, "bold"))
label_title.pack()
label_km = tk.Label(frame, text="Entrez le kilométrage :")
label_km.pack()
entry_km = tk.Entry(frame)
entry_km.pack()
btn_estimate = tk.Button(frame, text="Estimer le prix", command=estimate_price)
btn_estimate.pack()
label_result = tk.Label(frame, text="", font=("Arial", 12))
label_result.pack()
root.mainloop()
print("Erreur : Veuillez entrer un kilométrage valide.")