Deploying a Machine Learning Model as an API using FastAPI on Python
Deploying a Machine Learning Model as an API using FastAPI on Python
2. Prerequisites
Before proceeding, ensure the following are installed:
Required Libraries:
import pickle
This ensures that all request parameters follow the defined data structure.
prediction = Logistic_Regression.predict([input_list])
Receives JSON input, extracts values, and converts them into a list.
Passes the list to the trained model for prediction.
Returns a human-readable prediction response.
Using Postman
1. Open Postman.
2. Select POST request.
3. Enter API URL: http://127.0.0.1:8000/predict
4. Go to Body > raw > JSON and input:
5. {
6. "age": 45,
7. "sex": 1,
8. "cp": 3,
9. "trestbps": 130,
10. "chol": 233,
11. "fbs": 0,
12. "restecg": 1,
13. "thalachh": 150,
14. "exang": 0,
15. "oldpeak": 2.3,
16. "slope": 2,
17. "ca": 0,
18. "thal": 2,
19. "target": 1
}