Sameer-Handsome173's picture
Upload 5 files
3ded9fd verified
raw
history blame contribute delete
731 Bytes
from fastapi import FastAPI
from input_schemas import ModelInput
from model_predict import predict_output
app = FastAPI(
title="Road Safety Prediction API",
description="This API predicts accident severity or risk based on road and environment features using a Ridge model.",
version="1.0"
)
@app.get("/")
def home():
return {"message": "Welcome to the Road Safety Prediction API!"}
@app.post("/predict")
def get_prediction(input_data: ModelInput):
"""
Make prediction using the trained Ridge regression model.
"""
try:
prediction = predict_output(input_data)
return {"prediction": prediction}
except Exception as e:
return {"error": str(e)}