Sign inSign up

c9johnson/titanic-survival-api

By c9johnson

•Updated 2 months ago

Image
0

685

c9johnson/titanic-survival-api repository overview

⁠Titanic Survival Prediction API

A machine learning API that predicts passenger survival on the Titanic using a Random Forest classifier.

⁠Quick Start

⁠Run the API locally

docker pull yourusername/titanic-survival-api:latest docker run -p 8000:8000 yourusername/titanic-survival-api:latest

⁠Use the API

Visit http://localhost:8000/docs⁠ for interactive documentation.

⁠Example prediction:

curl -X POST "http://localhost:8000/predict⁠"
-H "Content-Type: application/json"
-d '{ "Pclass": 1, "Sex": "female", "Age": 30.0, "SibSp": 0, "Parch": 0, "Fare": 50.0, "Embarked": "S" }'

⁠Response:

{ "survived": 1, "survival_probability": 0.95, "prediction_confidence": "High", "passenger_profile": { "class": "Class 1", "gender": "female", "age_group": "Adult", "family_size": 1, "traveling_alone": true, "fare_level": "High", "embarkation_port": "Southampton" } }

⁠Model Performance

  • Algorithm: Random Forest Classifier
  • Accuracy: 85%+ on test data
  • Features: Passenger class, sex, age, family size, fare, embarkation port

⁠API Endpoints

  • GET / - Health check
  • POST /predict - Single passenger prediction
  • POST /predict-batch - Multiple passenger predictions
  • GET /model-info - Model metadata

⁠Input Parameters

ParameterTypeDescriptionExample
PclassintPassenger class (1, 2, 3)1
SexstrGender ('male', 'female')'female'
AgefloatAge in years30.0
SibSpintSiblings/spouses aboard0
ParchintParents/children aboard0
FarefloatTicket fare50.0
EmbarkedstrPort ('S', 'C', 'Q')'S'

⁠Development

⁠Training Environment

cd training docker build -t titanic-training . docker run -p 8888:8888 -v "$(pwd):/home/jovyan/work" titanic-training

⁠Local Development

cd serving pip install -r requirements.txt python app.py

⁠License

This project is for educational purposes.

Tag summary

Content type

Image

Digest

sha256:cdacae6a1…

Size

153.6 MB

Last updated

2 months ago

docker pull c9johnson/titanic-survival-api