mirror of
https://github.com/Ladebeze66/ft_linear_regression.git
synced 2025-12-15 13:46:48 +01:00
modifschool
This commit is contained in:
parent
a9b71d150a
commit
a5616622a3
4
main.py
4
main.py
@ -5,7 +5,7 @@ import os
|
|||||||
sys.path.append(os.path.abspath("src"))
|
sys.path.append(os.path.abspath("src"))
|
||||||
|
|
||||||
from src.training_model import train_model
|
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():
|
def main():
|
||||||
print("Bienvenue dans le modèle de prédiction de prix de voiture !")
|
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
|
from src.prediction import predict_price
|
||||||
# Lancer l'interface graphique après l'entraînement
|
# Lancer l'interface graphique après l'entraînement
|
||||||
print("Lancement de l'interface graphique...")
|
print("Lancement de l'interface graphique...")
|
||||||
show_gui(predict_price)
|
cli_interface(predict_price)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
numpy
|
numpy
|
||||||
pandas
|
pandas
|
||||||
matplotlib
|
matplotlib
|
||||||
seaborn
|
seaborn
|
||||||
tk
|
|
||||||
45
src/gui.py
45
src/gui.py
@ -1,36 +1,13 @@
|
|||||||
import tkinter as tk
|
def cli_interface(predict_price):
|
||||||
from tkinter import messagebox
|
"""Interface en ligne de commande pour entrer un kilométrage et voir le prix estimé."""
|
||||||
|
while True:
|
||||||
def show_gui(predict_price):
|
user_input = input("Entrez un kilométrage (ou 'q' pour quitter) : ")
|
||||||
"""Affiche l'interface graphique Tkinter pour entrer un kilométrage et voir le prix estimé."""
|
if user_input.lower() == 'q':
|
||||||
|
print("Fermeture du programme.")
|
||||||
def estimate_price():
|
break
|
||||||
try:
|
try:
|
||||||
km = float(entry_km.get()) # Récupère la valeur entrée
|
km = float(user_input)
|
||||||
price = predict_price(km) # Prédiction du prix
|
price = predict_price(km)
|
||||||
label_result.config(text=f"Prix estimé : {price:.2f} €", fg="green") # Affiche le prix
|
print(f"Prix estimé : {price:.2f} €")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
messagebox.showerror("Erreur", "Veuillez entrer un kilométrage valide.")
|
print("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()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user