feat: house price prediction model integration
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user