A Machine Learning model deployed as an API and used to predict if someone survived the Titanic crash. Built with TensorFlow(Keras), FastAPI and Docker.
The RMS Titanic, a luxury steamship, sank in the early hours of April 15, 1912, off the coast of Newfoundland in the North Atlantic after sideswiping an iceberg during its maiden voyage. Of the 2,240 passengers and crew on board, more than 1,500 lost their lives in the disaster.
So in this project I tried to develop an accurate model that could predict the chance of someone surviving the disaster
The data used was gotten from kaggle
In this project I tested 6 different classification algorithms namely:
- Decision Tree
- Random Forest
The final model used for the app was the Random Classifier model which had the best accuracy.
To run a demo do the following:
- Clone the repository.
- Install the requirements from the requirements.txt file:
pip install -r requirements.txt
- Then from your command line run:
python -m uvicorn --port 5000 --host 127.0.0.1 titanic_ml_api:app --reload
Then you can view the site on your local server: http://127.0.0.1:5000/
To build the docker container image;
- Install docker
- Clone the repository
- Then from your command line run:
docker build . -t titanicapi
- Run the docker container:
docker run -d --name mycontainer -p 5000:5000 titanicapi
Then you can view the site on your local server: http://127.0.0.1:5000/
The api can be deployed using the dockerfile or the procfile on heroku.
Assuming you have git and heroku cli installed just carry out the following steps:
- Clone the repository
git clone https://github.com/Nneji123/Titanic-Survival-Prediction-with-FastAPI-and-Docker.git
- Change the working directory
cd Titanic-Survival-Prediction-with-FastAPI-and-Docker
- Create the heroku app
heroku create your-app-name
Replace your-app-name with the name of your choosing.
- Set the heroku cli git remote to that app
heroku git:remote your-app-name
- Set the heroku stack setting to container
heroku stack:set container
- Push to heroku
git push heroku main
- Clone the repository and copy the contents to your own repository on github
- Deploy with Github and Heroku then you're done.
The api and its documentation can be viewed here: https://titanic-prediction-new.herokuapp.com/docs or https://titanic-prediction-new.herokuapp.com/redoc