initial commit

This commit is contained in:
Patrick Huembeli
2025-02-19 10:23:52 +01:00
parent 59b008d8f8
commit ca7b2e3315
8 changed files with 117 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
from fastapi import APIRouter, HTTPException
from app.models.prediction import HousePredictionInput, HousePredictionOutput
from app.services.ml_model import HousePricePredictor
router = APIRouter()
model = HousePricePredictor()
@router.post("/predict",
response_model=HousePredictionOutput,
summary="Predict house price",
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))