This API is designed to predict property prices based on geographical coordinates. It utilizes a decision tree model to estimate property prices per square meter at a given latitude and longitude.
- URL:
/predict_get
- Method:
GET
- Query Params:
latitude=[float]
(required)longitude=[float]
(required)
- Success Response: JSON object with the predicted price per square meter.
- Error Response:
- 400 Bad Request if query parameters are missing or invalid
- 503 Service Unavailable if the model is not loaded
- 500 Internal Server Error for other issues
- Example:
http://localhost:5000/predict_get?latitude=48.8566&longitude=2.3522
- Ensure FastAPI, Uvicorn, and necessary dependencies are installed.
- Load the decision tree model named
decision_tree_model.pkl
. - Run the server using
uvicorn main:app --host=localhost --port=5000
, withmain.py
being the script containing the FastAPI app. - Access the API at
http://localhost:5000
.
- Custom error handling is implemented to manage internal server errors.
- The server returns appropriate error messages and HTTP status codes based on the nature of the error encountered.
- The API checks for the model's availability before making predictions, ensuring reliable responses.