A simple ML model served as a REST API using FastAPI and Docker. The model predicts Titanic survival based on age, passenger class, and alone status.
ml-fastapi-docker/
├── main.py
├── train.py
├── model.joblib
├── requirements.txt
├── Dockerfile
└── README.md
Install dependencies: pip install -r requirements.txt
Run the app: uvicorn main:app --reload
Build the image: docker build -t ml-fastapi-app .
Run the container: docker run -p 8000:8000 ml-fastapi-app
GET / — returns {"message": "ML API is running"} POST /predict — returns survival prediction
{ "age": 25, "pclass": "First", "alone": 0 }
{ "prediction": "survived" }
Open http://localhost:8000/docs in your browser to access the Swagger UI. (click POST/predict -> Try it out -> change the input -> Execute)