add: estimate program

This commit is contained in:
2025-05-04 21:43:08 +02:00
parent cced4eb994
commit 7ea0221630
3 changed files with 36 additions and 2 deletions

19
estimate.py Normal file
View File

@@ -0,0 +1,19 @@
import pandas as pd
class Estimate:
def __init__(self, thetas_path="thetas.csv"):
self.path = thetas_path
self.theta0 = 0
self.theta1 = 0
self.get_thetas()
def get_thetas(self):
with open(self.path, 'r') as file:
self.data = pd.read_csv(file)
self.theta0 = self.data["theta0"].iloc[0]
self.theta1 = self.data["theta1"].iloc[0]
def estimate_price(self, mileage):
return self.theta0 + (self.theta1 * mileage)
estimate = Estimate()
input = int(input("Please enter the mileage of your car: "))
print("The estimated price for a", input, "kilometers car is :", estimate.estimate_price(input))