{"id":51197821,"url":"https://github.com/jubairt/titanic-model-deployment-fastapi-docker","last_synced_at":"2026-06-27T22:02:33.630Z","repository":{"id":329599186,"uuid":"1120159586","full_name":"jubairt/Titanic-model-deployment-fastapi-docker","owner":"jubairt","description":"A simple machine learning project demonstrating how to deploy a trained model as a REST API using FastAPI and Docker.","archived":false,"fork":false,"pushed_at":"2025-12-21T03:43:01.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-31T09:22:26.814Z","etag":null,"topics":["docker","fastapi","ml","model-serving","titanic-survival-prediction"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jubairt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T16:01:07.000Z","updated_at":"2025-12-24T06:36:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jubairt/Titanic-model-deployment-fastapi-docker","commit_stats":null,"previous_names":["jubairt/model-deployment-fastapi-docker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jubairt/Titanic-model-deployment-fastapi-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubairt%2FTitanic-model-deployment-fastapi-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubairt%2FTitanic-model-deployment-fastapi-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubairt%2FTitanic-model-deployment-fastapi-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubairt%2FTitanic-model-deployment-fastapi-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jubairt","download_url":"https://codeload.github.com/jubairt/Titanic-model-deployment-fastapi-docker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubairt%2FTitanic-model-deployment-fastapi-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34869004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastapi","ml","model-serving","titanic-survival-prediction"],"created_at":"2026-06-27T22:02:32.813Z","updated_at":"2026-06-27T22:02:33.622Z","avatar_url":"https://github.com/jubairt.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Titanic Survival Prediction API 🚢\n\nThis project demonstrates a **complete, real-world machine learning deployment workflow** — from a trained model to a **production-ready REST API** served using **FastAPI** and **Docker**.\n\nThe goal of this project is to show **how a trained ML model can be packaged, served, and deployed** in a clean, simple, and professional way.\n\n---\n\n```bash\ndocker build -t titanic-model-fastapi .\ndocker run -p 8000:8000 titanic-model-fastapi\n```\n- Run these commands in the project folder to create docker image and run the container\n\n## 🚀 What This Project Does\n\nThis API predicts whether a passenger **survived or did not survive** the Titanic disaster based on a small set of easy-to-understand inputs.\n\nThe focus is **not on complex modeling**, but on **correct deployment practices** that reflect how ML systems are built in real-world production environments.\n\n---\n\n## 🧠 Machine Learning Approach\n\n- A **Logistic Regression** model is used for prediction.\n- The model is trained **offline** using the Titanic dataset.\n- Only **5 meaningful and user-friendly features** are used.\n- All preprocessing (encoding) is bundled together with the model using a **scikit-learn Pipeline**.\n\nThis ensures the same preprocessing logic is applied during both training and inference.\n\n---\n\n## 📥 Model Inputs\n\nThe API expects the following passenger details:\n\n- **Passenger Class (`Pclass`)**  \n  Travel class of the passenger (1 = First, 2 = Second, 3 = Third)\n\n- **Sex (`Sex`)**  \n  Gender of the passenger (`male` or `female`)\n\n- **Age (`Age`)**  \n  Age of the passenger in years\n\n- **Fare (`Fare`)**  \n  Ticket price paid by the passenger\n\n- **Embarked (`Embarked`)**  \n  Port where the passenger boarded the ship  \n  (`S` = Southampton, `C` = Cherbourg, `Q` = Queenstown)\n\nAll inputs are provided in raw form — the API handles preprocessing internally.\n\n---\n\n## 📤 API Output\n\nThe API returns:\n\n- A **numeric prediction**\n  - `1` → Passenger survived\n  - `0` → Passenger did not survive\n\n- A **human-readable message** explaining the prediction\n\nThis dual output design makes the API suitable for both machines and humans.\n\n---\n\n## 🌐 API Endpoints\n\n- **Health Check**\n  - Confirms the service is running and responsive\n\n- **Prediction Endpoint**\n  - Accepts passenger data as JSON\n  - Returns survival prediction and explanation\n\nInteractive API documentation is automatically generated and available via **Swagger UI**.\n\n---\n\n## 🐳 Docker \u0026 Deployment\n\nThe application is fully **containerized using Docker**.\n\nKey deployment principles followed:\n\n- The model is trained **outside** the container\n- The container contains **only what is needed for inference**\n- Training code, notebooks, and datasets are excluded using `.dockerignore`\n- Dependencies are installed efficiently using Docker layer caching\n- The API runs in a reproducible, portable environment\n\nThis makes the service easy to run locally, deploy to the cloud, or scale in container orchestration systems.\n\n---\n\n## 🧩 Technologies Used\n\n- **Python**\n- **FastAPI** — REST API framework\n- **scikit-learn** — Model training \u0026 pipelines\n- **pandas / numpy** — Data handling\n- **Pydantic** — Input validation\n- **Docker** — Containerization\n- **Uvicorn** — ASGI server\n\n---\n\n## 🧠 Key Learning Outcomes\n\nThis project demonstrates:\n\n- How to serve ML models using REST APIs\n- Why preprocessing must be bundled with the model\n- How FastAPI and Pydantic enable clean input validation\n- How Docker is used in real ML production systems\n- The difference between training environments and serving environments\n- Best practices for deploying ML models in a professional setting\n\n---\n\n## 📌 Why This Project Matters\n\nMost ML projects stop at training.\n\nThis project goes further by showing **how models are actually deployed**, which is the most common gap between learning ML and working in real-world ML systems.\n\nIt is designed to be:\n- Beginner-friendly\n- Interview-ready\n- Production-oriented\n- Easy to extend and improve\n\n---\n\n## 🔮 Possible Enhancements\n\n- Add prediction probabilities\n- Add stricter input validation rules\n- Introduce model versioning\n- Push Docker image to a container registry\n- Deploy to cloud platforms (AWS / Azure / GCP)\n- Add logging and monitoring\n\n---\n\n## ✅ Summary\n\nThis project is a complete example of **end-to-end ML deployment** using modern, industry-standard tools.  \nIt focuses on **clarity, correctness, and real-world relevance**, making it suitable for learning, portfolios, and interviews.\n\n---\n\n**Author**  \nBuilt as part of a hands-on journey into Machine Learning deployment and MLOps.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjubairt%2Ftitanic-model-deployment-fastapi-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjubairt%2Ftitanic-model-deployment-fastapi-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjubairt%2Ftitanic-model-deployment-fastapi-docker/lists"}