diff --git a/CenaMieszkaniaDesign.py b/CenaMieszkaniaDesign.py index 76d0761..33249c4 100644 --- a/CenaMieszkaniaDesign.py +++ b/CenaMieszkaniaDesign.py @@ -1,7 +1,32 @@ from tkinter import * +import joblib +import pandas as pd root = Tk() +def calculate_price(): + # Get the selected values and entry input + stan = selected_stan.get() + liczba_pokoi = selected_liczba_pokoi.get() + metraz = entry1.get() + rynek = selected_rynek.get() + + # Create a dictionary with the data + data = {'stan': [stan], 'l pokoi': [liczba_pokoi], 'metraż': [metraz], 'rynek': [rynek]} + + # Create a DataFrame from the dictionary + X = pd.DataFrame(data) + + # Load the model and make predictions + loaded_model = joblib.load('ridge_model.sav') + result = loaded_model.predict(X) + result = result / float(metraz) + + # Display the result + result_label.config(text=f"Predicted Price: {result[0]:.2f} PLN") + result_label.grid(row=6, column=1, padx=10, pady=5) + + root.geometry("500x500") root.title("Mieszkaneo") @@ -15,7 +40,7 @@ entry1.grid(row=1, column=0, padx=10, pady=5) label2 = Label(root, text="Rynek", font=('Arial', 18)) label2.grid(row=0, column=1, padx=10, pady=5) -rynek_options = ["Pierwotny", "Wtórny"] +rynek_options = ["pierwotny", "wtórny"] selected_rynek = StringVar() selected_rynek.set(rynek_options[0]) @@ -25,7 +50,7 @@ rynek_menu.grid(row=1, column=1, padx=10, pady=5) label3 = Label(root, text="Stan", font=('Arial', 18)) label3.grid(row=2, column=0, padx=10, pady=5) -stan_options = ["Do remontu", "Wykończone"] +stan_options = ["do zamieszkania", "do wykończenia","do remontu"] selected_stan = StringVar() selected_stan.set(stan_options[0]) @@ -43,8 +68,12 @@ liczba_pokoi_menu = OptionMenu(root, selected_liczba_pokoi, *liczba_pokoi_option liczba_pokoi_menu.config(font=('Arial', 18), bg='white', fg='black') # Kolory tła i tekstu liczba_pokoi_menu.grid(row=3, column=1, padx=10, pady=5) -button = Button(root, text="Oblicz cenę mieszkania", font=('Arial', 18)) +button = Button(root, text="Oblicz cenę mieszkania", font=('Arial', 18), command=calculate_price) button.config(bg='green', fg='white') # Kolory tła i tekstu button.grid(row=4, columnspan=2, padx=10, pady=10) +result_label = Label(root, text="", font=('Arial', 18)) +result_label.grid(row=5, columnspan=2, padx=10, pady=5) + + root.mainloop() diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3c2a521 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,23 @@ +pipeline { + agent { + docker { image 'python:3.10.6-slim-bullseye' } + } + + stages { + stage('Build') { + steps { + echo 'Building..' + } + } + stage('Test') { + steps { + sh 'check_flat_price.py' + } + } + stage('Deploy') { + steps { + echo 'Deploying....' + } + } + } +} \ No newline at end of file diff --git a/check_flat_price.py b/check_flat_price.py new file mode 100644 index 0000000..4d66148 --- /dev/null +++ b/check_flat_price.py @@ -0,0 +1,8 @@ +import pandas as pd +import numpy as np + +ceny = pd.read_csv('expected.tsv', sep='\t', header=None) + +for cena in ceny: + if cena < 0: + print("cena ujemna, sprawdz cene") \ No newline at end of file