Spaces:
No application file
No application file
| 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" | |
| ) | |
| def home(): | |
| return {"message": "Welcome to the Road Safety Prediction API!"} | |
| 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)} | |