FastAPI + scikit-learn API that predicts Titanic passenger survival. Run it with one docker command.
82
A machine learning API that predicts whether a Titanic passenger would have survived, using a Random Forest classifier. Pull it and run it with one command, no Python setup needed.
Try it live (no install): vfoster-repo.github.io/ml-model-api-project
Source code: github.com/vfoster-repo/ml-model-api-project
docker pull vfoster2docker/titanic-survival-api:latest
docker run -p 8000:8000 vfoster2docker/titanic-survival-api:latest
Then open http://localhost:8000/docs in your browser to try it out.
If port 8000 is already in use on your computer, change the first number, for example -p 8080:8000, and go to http://localhost:8080/docs instead.
| Tag | What it is |
|---|---|
latest | The newest version |
v1.0 | First release (same image as latest right now) |
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.92,
"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"
}
}
| Method | Endpoint | What it does |
|---|---|---|
| GET | / | Health check |
| POST | /predict | Prediction for one passenger |
| POST | /predict-batch | Predictions for a list of passengers |
| GET | /model-info | Model details and accuracy |
| Parameter | Type | Description | Example |
|---|---|---|---|
| Pclass | int | Passenger class (1, 2, 3) | 1 |
| Sex | str | Gender ('male', 'female') | 'female' |
| Age | float | Age in years (0 to 100) | 30.0 |
| SibSp | int | Siblings/spouses aboard | 0 |
| Parch | int | Parents/children aboard | 0 |
| Fare | float | Ticket fare | 50.0 |
| Embarked | str | Port ('S', 'C', 'Q') | 'S' |
The API checks these values before predicting. For example, "Sex": "Male" (capital M) or "Pclass": 4 gets a clear error back instead of a wrong prediction.
train.csv (891 passengers)You can see the full training run, with charts, in the training notebook on GitHub.
python:3.13-slimappuser), not rootdocker ps shows healthy once the API is upVictor Foster
Completed as part of the TripleTen AI/ML Engineering program, Sprint 11 "Project: Docker and Containerization".
Content type
Image
Digest
sha256:28fc91064…
Size
146.8 MB
Last updated
11 days ago
docker pull vfoster2docker/titanic-survival-api