-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.py
More file actions
32 lines (25 loc) · 779 Bytes
/
predict.py
File metadata and controls
32 lines (25 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
def main():
theta0 = 0.0
theta1 = 0.0
theta_loaded = False
try:
with open("theta.json", "r") as f:
data = json.load(f)
theta0 = data["theta0"]
theta1 = data["theta1"]
theta_loaded = True
except FileNotFoundError:
pass
while True:
try:
mileage = float(input("Enter car mileage (km): "))
if not theta_loaded:
print("Warning: Missing theta.json - Using default parameters (Run training)")
price = theta0 + (theta1 * mileage)
print(f"Price estimated: {price:.2f}")
break
except ValueError:
print("Error: Please enter a valid number")
if __name__ == "__main__":
main()