This is a FastAPI-based application that predicts whether a person is diabetic based on several health parameters using a pre-trained machine learning model.
- Prediction Endpoint: Accepts multiple health-related parameters via query parameters and returns a prediction (
diabetic
ornot diabetic
). - The model is pre-trained and saved using
scikit-learn
.
The API uses a machine learning model trained to predict whether a person is diabetic or not based on the following input parameters:
pregnancies
(int): Number of pregnanciesGlucose
(int): Glucose levelBloodPressure
(int): Blood pressure level (mm Hg)SkinThickness
(int): Triceps skin fold thickness (mm)Insulin
(int): 2-Hour serum insulin (mu U/ml)BMI
(float): Body Mass Index (weight in kg / (height in m²))DiabetesPedigreeFunction
(float): Diabetes pedigree functionAge
(int): Age of the person
The API responds with a JSON object that contains the result:
{
"result": "The person is diabetic" // or "The person is not diabetic"
}
You can make requests to the following URL:
https://diabetes-prediction-model-5d9550a8d37f.herokuapp.com/docs
pregnancies
: IntegerGlucose
: IntegerBloodPressure
: IntegerSkinThickness
: IntegerInsulin
: IntegerBMI
: FloatDiabetesPedigreeFunction
: FloatAge
: Integer
Alternatively, instead of Swagger UI, you can directly enter the following URL into your browser with the parameters you want:
https://diabetes-prediction-model-5d9550a8d37f.herokuapp.com/api/diabetes_prediction?pregnancies=2&Glucose=120&BloodPressure=80&SkinThickness=20&Insulin=85&BMI=25.5&DiabetesPedigreeFunction=0.5&Age=33
{
"result": "The person is not diabetic"
}
The project uses the following dependencies:
- FastAPI
- Uvicorn
- scikit-learn
- Pydantic
- Requests
Ensure that you install all dependencies listed in requirements.txt
before running the project.
To run the project locally:
-
Clone the repository:
git clone https://github.com/dev-achintha/-test-ML_Model_Deployement_using_Fast_API.git
-
Install dependencies:
pip install -r requirements.txt
-
Run the FastAPI application:
uvicorn main:app --reload
-
Visit
http://127.0.0.1:8000/docs
in your browser to interact with the API using the FastAPI Swagger UI.