More setup

This commit is contained in:
Jacob Windsor
2025-02-19 12:39:01 +01:00
parent 239068e7f6
commit 861eac6d46
8 changed files with 128 additions and 31 deletions
-27
View File
@@ -1,27 +0,0 @@
from fastapi import APIRouter, HTTPException
from app.models.prediction import HousePredictionInput, HousePredictionOutput
from app.services.ml_model import HousePricePredictor
router = APIRouter()
model = HousePricePredictor()
@router.get("/predictions/house-price",
response_model=HousePredictionOutput,
summary="Get a house price prediction",
description="Predicts the price of a house based on its features"
)
async def predict_price(input_data: HousePredictionInput) -> HousePredictionOutput:
try:
predicted_price, confidence_score, similar_listings = model.predict(
input_data.square_feet,
input_data.bedrooms,
input_data.bathrooms
)
return HousePredictionOutput(
predicted_price=predicted_price,
confidence_score=confidence_score,
similar_listings=similar_listings
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))