This is just a playground for me to make an API with various datasets and machine learning algorithms.
It utilizes the following technologies:
- Server
- FastAPI
- Numpy
- Pandas
- TensorFlow
- Keras
- MatplotLib
- Sci-Kit Learn
- Jupyter Notebook
- Pickle
All code in this repository is constructed using Python. This is built using Docker, so you will need Docker to run it.
There are various datasets, models, and features used throughout this API. Since it's a way for me to introduce myself to machine learning, this API has multiple use cases and does not have one story tying it all together.
This project contains:
- Grade Predictor
- Heart Disease Predictor
-
Grade Predictor
- Endpoint
/predict/grade
- Method
- Multivariable Linear Regression
- Query Parameter Inputs
sex
- Student's biological sex
- int (Female = 1, Male = 0)
age
- Student's current age
- int (0 - 100)
absences
- Number of absences student has
- int (0 - 93)
failures
- Number of classes a student has failed in the past
- int (0 - 4)
activities
- Whether or not a student participates in extracurricular activities or not
- int (Yes = 1, No = 0)
internet
- Whether or not a student has internet access at home
- int (Yes = 1, No = 0)
midterm1
- Grade the student received on the first midterm
- int (0 - 100)
midterm2
- Grade the student received on the second midterm
- int (0 - 100)
- Output
grade
- Predicted grade for the student's final exam
- int (0 - 100)
- Accuracy
- 72.94%
- Endpoint
-
Heart Disease Predictor
- Endpoint
/predict/heartdisease
- Method
- Single Class Logistic Regression
- Query Parameter Inputs
sex
- Patient's biological sex
- int (Female = 1, Male = 0)
age
- Patient's current age
- int (0 - 100)
daily_cigs
- Number of cigarettes patient smokes a day
- int (0 - 40)
is_on_bp_meds
- Whether or not a patient is on blood pressure medication
- int (Yes = 1, No = 0)
has_stroke_risk
- Whether or not a patient is at risk for a stroke
- int (Yes = 1, No = 0)
has_diabetes
- Whether or not a patient has diabetes
- int (Yes = 1, No = 0)
cholestrol
- Patient's standard cholestrol rate
- int (100 - 400)
bp
- Patient's standard blood pressure
- float (50 - 120)
bmi
- Patient's Body Mass Index (BMI)
- float (15 - 40)
heart_rate
- Patient's standard heart rate in BPM
- int (50 - 120)
- Output
has_heart_disease
- Prediction if patient has heart disease or not
- boolean
confidence
- Probability of prediction being correct
- float (0 - 100)
- Accuracy
- 85.38%
- Endpoint
-
Handwritten Digit Classifier
- Endpoint
/predict/digits
- Method
- Keras Neural Network
- Input Layer: Flattened
- Hidden Layer 1 & 2: Dense 128 Node with ReLU Activation
- Output Layer: Dense 10 Node with Softmax Activation
- Keras Neural Network
- File Body Inputs (NOTE: This is Form Data!!!)
img
- Image File
- FastAPI File
- Output
digit
- Predicted Digit
- int (0 - 9)
confidence
- Probability of prediction being correct
- float (0 - 100)
- Accuracy
- 96.97%
- Endpoint
DISCLAIMER: Make sure you're on Python 3.8+
Set Up Virtual Environment
cd api
virtualenv -p python3 env
source env/bin/activate
pip install -r requirements.txt
Students Dataset
Please download students.zip
from this link. Extract the zip file. Copy student-mat.csv
to /api/data/GPA/
.
Heart Disease Dataset
Please download framingham_heard_disease.csv
from this link. Rename the file to heart-disease.csv
and copy it to /api/data/Heart
.
Open Virtual Environment
source env/bin/activate
Run API
make up
Run API Silently (Without Logging)
make up-quiet
Stop API
make down
Run the following commands in the server directory
Install New Dependencies
source env/bin/activate
pip install [dependency]
make freeze
Install All Dependencies
pip install -r requirements.txt
Deactivate Python Environment (if active)
deactivate
-
Advaith Nair
- Full Stack Developer
- Website