feat: house price prediction model integration

This commit is contained in:
nasim
2025-04-03 10:14:54 +02:00
parent 72375db5cd
commit 3aa78be3d6
22 changed files with 251 additions and 24 deletions
+12 -11
View File
@@ -1,16 +1,17 @@
import os
import joblib
import numpy as np
from backend.app.dtos.house.house_features import HouseFeatures
class HousePricePredictor:
"""
Mock ML model that predicts house prices.
In a real scenario, this would load a trained model.
"""
async def predict(
self, square_feet: float, bedrooms: int, bathrooms: float
) -> float:
base_price = square_feet * 200
bedroom_value = bedrooms * 25000
bathroom_value = bathrooms * 15000
predicted_price = base_price + bedroom_value + bathroom_value
return predicted_price
def __init__(self):
self.model = joblib.load("backend/app/ai_models/price_predictor.pkl")
def predict(self, features: HouseFeatures) -> float:
X = np.array([[features.square_feet, features.bedrooms, features.bathrooms]])
return self.model.predict(X)[0] * 100000