Skip to content

ranmerc/pcos-prediction-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCOS Prediction API

PCOS Prediction API built with FastAPI and deployed on render.

Machine learning model built with Google Colab.

Docs available at /docs.

Running on Local Machine

  1. Clone repository
git clone https://github.com/ranmerc/pcos-prediction-backend.git
  1. Create Virtual Environment
# Creates Virtual Environment named venv
python -m venv venv
  1. Activate venv
source venv/Scripts/activate
  1. Install packages
pip install -r requirements.txt
  1. Running Uvicorn Server
uvicorn main:app --reload
  1. Deactivating Virtual Environment
deactivate
  • Generating requirements.txt
pip freeze > requirements.txt

How it works?

We pickle the trained model and StandardScaler object -

import pickle
pickle.dump(model, open("model.sav", 'wb'))
pickle.dump(standard_scalar, open("sc.sav", 'wb'))

Then we load the model on server and make prediction using it -

loaded_model = pickle.load(open("model.sav", 'rb'))
sc = pickle.load(open("sc.sav", 'rb'))

test_data = []
test_data = sc.transform([test_data])
res = loaded_model.predict(test_data)

Reference

  • Can not activate a virtualenv in GIT bash mingw32 for Windows on Stack Overflow

  • Is it bad to have my virtualenv directory inside my git repository? on Stack Overflow

  • Python Tutorial: VENV (Windows) - How to Use Virtual Environments with the Built-In venv Module by Cory Schafer on Youtube

  • Deploying FastAPI application to Render by Akash R Chandran

  • What and why behind fit_transform() and transform() in scikit-learn! by Towards Data Science