From 6d0b501620b22ccbff68802821b0478e29687fba Mon Sep 17 00:00:00 2001 From: Jacob Windsor Date: Wed, 19 Feb 2025 13:27:02 +0100 Subject: [PATCH] Use a prediciton dataclass --- backend/app/models/prediction.py | 12 ------------ backend/app/services/house_price_predictor.py | 13 +++++++++++-- 2 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 backend/app/models/prediction.py diff --git a/backend/app/models/prediction.py b/backend/app/models/prediction.py deleted file mode 100644 index 8a51284..0000000 --- a/backend/app/models/prediction.py +++ /dev/null @@ -1,12 +0,0 @@ -from pydantic import BaseModel, Field -from typing import List - -class HousePredictionInput(BaseModel): - square_feet: float = Field(..., gt=0, description="Square footage of the house") - bedrooms: int = Field(..., ge=1, description="Number of bedrooms") - bathrooms: float = Field(..., gt=0, description="Number of bathrooms") - -class HousePredictionOutput(BaseModel): - predicted_price: float - confidence_score: float - similar_listings: List[float] \ No newline at end of file diff --git a/backend/app/services/house_price_predictor.py b/backend/app/services/house_price_predictor.py index 3a64818..4dec226 100644 --- a/backend/app/services/house_price_predictor.py +++ b/backend/app/services/house_price_predictor.py @@ -1,5 +1,14 @@ import random from typing import List, Tuple +from dataclasses import dataclass + + +@dataclass +class Prediction: + predicted_price: float + confidence_score: float + similar_listings: List[float] + class HousePricePredictor: """ @@ -11,7 +20,7 @@ class HousePricePredictor: # Mock initialization - in reality would load model weights pass - def predict(self, square_feet: float, bedrooms: int, bathrooms: float) -> Tuple[float, float, List[float]]: + def predict(self, square_feet: float, bedrooms: int, bathrooms: float) -> Prediction: """ Mock prediction method that returns: - predicted price @@ -32,4 +41,4 @@ class HousePricePredictor: for _ in range(3) ] - return predicted_price, confidence_score, similar_listings \ No newline at end of file + return Prediction(predicted_price, confidence_score, similar_listings)