This project aims to develop machine learning models to test for Testosterone Deficiency in patients. The dataset used contains information on 3397 patients considered for Testosterone Deficiency. The dataset has been ethically approved by the Research Ethics Committee of the State University of Feira de Santana, Bahia, Brazil, under approval code: 3,057,301.
- Created a colab notebook where I performed EDA and experimented with various parameters to successfully create 5 ML models.
- Then, created a local environment for VS Code.
- Created a
main.pyfile to build a Streamlit file as the frontend. - Simultaneously, created utils files
get_data.py,get_model.py,get_prediction.pyas the backend to process data, load pre-trained models from.pkland.pthfiles, and then createdoutputsfile to generate predictions. - Now, built a Docker image using a Dockerfile to store in
Azure Container Registryso that we could deploy this ML app using Docker.
| Model | Accuracy | Precision | Specificity | Sensitivity | F1 Score | ROC AUC |
|---|---|---|---|---|---|---|
| SVM | 88.62 | 92.70 | 92.70 | 82.33 | 87.20 | 0.8827 |
| RF | 85.88 | 84.25 | 84.25 | 86.13 | 85.18 | 0.8589 |
| XGB | 86.20 | 87.26 | 87.26 | 82.77 | 84.96 | 0.8601 |
| KNN | 80.72 | 73.08 | 73.08 | 93.51 | 82.04 | 0.8142 |
| ANN | 81.05 | 76.17 | 76.17 | 87.05 | 81.25 | 0.8138 |
- Support Vector Machine (SVM)
- Random Forest (RF)
- XGBoost (XGB)
- k-Nearest Neighbors (KNN)
- Artificial Neural Network (ANN)
- Install required dependencies on local:
pip install -r requirements.txt
- Test the streamlit app on local:
streamlit run main.py
(Note: Run as administrator on Windows and remove "sudo" in commands)
- Important - Make sure you have installed Docker on your PC:
- Linux: Docker
- Windows/Mac: Docker Desktop
- Start Docker:
- Linux (Home Directory):
sudo systemctl start docker - Windows: You can start Docker engine from Docker Desktop.
- Build Docker image from the project directory:
sudo docker build -t Image_name:tag .
(Note: Rerun the Docker build command if you want to make any changes to the code files and redeploy.)
- Switch to Home Directory:
cd ~
List the built Docker images
$ sudo docker images
- Start a container:
sudo docker run -p 8501:8501 Image_ID
-
This will display the URL to access the Streamlit app (http://0.0.0.0:8501). Note that this URL may not work on Windows. For Windows, go to http://localhost:8501.
-
In a different terminal window, you can check the running containers with:
sudo docker ps
- Stop the container:
- Use
ctrl + cor stop it from Docker Desktop.
- Check all containers:
sudo docker ps -a
- Delete the container if you are not going to run this again:
sudo docker container prune
-
Sign up on Docker Hub.
-
Create a repository on Docker Hub.
-
Log in to Docker Hub from the terminal. You can log in with your password or access token.
sudo docker login
- Tag your local Docker image to the Docker Hub repository:
sudo docker tag Image_ID username/repo-name:tag
- Push the local Docker image to the Docker Hub repository:
sudo docker push username/repo-name:tag
(If you want to delete the image, you can delete the repository in Docker Hub and force delete it locally.)
- Command to force delete an image (but don't do this yet):
$ sudo docker rmi -f IMAGE_ID
- Anmol Chhetri
- I express my gratitude to UroS, the research group in Urology and Population Subgroups, from the Medical School, Universidade Estadual de Feira de Santana, for providing this valuable dataset.


