{"id":20164198,"url":"https://github.com/uday160386/ml-model-as-rest-api","last_synced_at":"2026-05-07T01:35:28.856Z","repository":{"id":240450113,"uuid":"802669706","full_name":"uday160386/ml-model-as-rest-api","owner":"uday160386","description":" A simple example on how to provide ML model (DecissionTreeClassifier) as a REST Service. The app is containerize and deployed in Azure Cloud ","archived":false,"fork":false,"pushed_at":"2025-08-25T10:22:09.000Z","size":93591,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-25T12:32:58.953Z","etag":null,"topics":["ai-ml","fastapi","machine-learning","machine-learning-algorithms","ml-ops","python","vuk-ai-cloud"],"latest_commit_sha":null,"homepage":"","language":"Python","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/uday160386.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}},"created_at":"2024-05-18T23:47:39.000Z","updated_at":"2025-08-25T10:22:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"7dcfdc73-b25c-4265-8208-6f7d150ebffc","html_url":"https://github.com/uday160386/ml-model-as-rest-api","commit_stats":null,"previous_names":["uday160386/ml-model-as-rest-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uday160386/ml-model-as-rest-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uday160386%2Fml-model-as-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uday160386%2Fml-model-as-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uday160386%2Fml-model-as-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uday160386%2Fml-model-as-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uday160386","download_url":"https://codeload.github.com/uday160386/ml-model-as-rest-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uday160386%2Fml-model-as-rest-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32719570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T00:29:05.620Z","status":"ssl_error","status_checked_at":"2026-05-07T00:28:57.074Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ai-ml","fastapi","machine-learning","machine-learning-algorithms","ml-ops","python","vuk-ai-cloud"],"created_at":"2024-11-14T00:33:34.780Z","updated_at":"2026-05-07T01:35:28.850Z","avatar_url":"https://github.com/uday160386.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ML Model Integration and Deployment\n\nSupervised(DecisionTreeClassifier) machine learning algorithm, that trains on the Iris dataset, exposes it as a REST API using FastAPI, and deploys it as an Azure Function for scalable predictions.\n\n## 🚀 Features\n\n- **Machine Learning Model**: DecisionTreeClassifier trained on the famous Iris dataset\n- **REST API**: FastAPI-powered endpoints with automatic documentation\n- **Cloud Deployment**: Serverless deployment on Azure Functions\n- **Containerization**: Docker support for consistent environments\n\n\n## 🏃‍♂️ Quick Start\n\n### Prerequisites\n\n- Python 3.8+\n- pip or conda\n- Docker (optional)\n- Azure CLI (for Azure deployment)\n\n### Local Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd ml-model-deployment\n   ```\n\n2. **Install dependencies**\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. **Run the application**\n   ```bash\n   uvicorn main:app --reload\n   ```\n\n4. **Access the application**\n   - API: http://localhost:8000\n   - Interactive docs: http://localhost:8000/docs\n   - Alternative docs: http://localhost:8000/redoc\n\n## 📚 API Documentation\n\n### Endpoints\n\n#### `POST /predict`\nPredict the Iris species based on flower measurements.\n\n**Request Body:**\n```json\n{\n  \"sepal_length\": 5.1,\n  \"sepal_width\": 3.5,\n  \"petal_length\": 1.4,\n  \"petal_width\": 0.2\n}\n```\n\n**Response:**\n```json\n{\n  \"prediction\": \"setosa\",\n  \"confidence\": 0.95,\n  \"all_probabilities\": {\n    \"setosa\": 0.95,\n    \"versicolor\": 0.03,\n    \"virginica\": 0.02\n  }\n}\n```\n\n\n## 🐳 Docker Deployment\n\n\n```bash\ndocker run -p 8000:8000 venmaum/ml-simple-app\n```\n## ☁️ Azure Functions Deployment\n\n### Prerequisites\n\n- Azure CLI installed and configured\n- Azure Functions Core Tools\n\n### Deployment Steps\n\n1. **Login to Azure**\n   ```bash\n   az login\n   ```\n\n2. **Create Resource Group**\n   ```bash\n   az group create --name ml-app-rg --location eastus\n   ```\n\n3. **Deploy Function App**\n   ```bash\n   func azure functionapp publish \u003cfunction-app-name\u003e\n   ```\n\n4. **Test the deployed function**\n   ```bash\n   curl -X POST https://\u003cfunction-app-name\u003e.azurewebsites.net/api/predict \\\n   -H \"Content-Type: application/json\" \\\n   -d '{\"sepal_length\": 5.1, \"sepal_width\": 3.5, \"petal_length\": 1.4, \"petal_width\": 0.2}'\n   ```\n\n## 🌺 Dataset Information\n\n**Iris Dataset** from scikit-learn:\n- **Samples**: 150\n- **Features**: 4 (sepal length, sepal width, petal length, petal width)\n- **Classes**: 3 (Setosa, Versicolor, Virginica)\n- **Type**: Multiclass classification\n\nThe dataset is automatically loaded and preprocessed when training the model.\n\n## 📁 Project Structure\n\n```\nml-model-deployment/\n├── main.py                 # FastAPI application\n├── model/\n│   ├── __init__.py\n│   ├── train.py           # Model training script\n│   └── iris_model.joblib  # Trained model file\n├── requirements.txt       # Python dependencies\n├── Dockerfile            # Docker configuration\n└── README.md           # This file\n```\n\n## 🛠️ Development\n\n### Setting up Development Environment\n\n1. **Create virtual environment**\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n   ```\n\n2. **Install development dependencies**\n   ```bash\n   pip install -r requirements-dev.txt\n   ```\n\n\n## 🧪 Testing\n\n### Manual Testing\n\nUse the provided examples in the interactive documentation or test with curl:\n\n```bash\ncurl -X POST \"http://localhost:8000/predict\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\n  \"sepal_length\": 6.3,\n  \"sepal_width\": 2.5,\n  \"petal_length\": 5.0,\n  \"petal_width\": 1.9\n}'\n```\n\n\n## 📊 Model Performance\n\n- **Accuracy**: ~96% on test set\n- **Training Time**: \u003c 1 second\n- **Prediction Time**: \u003c 10ms per request\n- **Model Size**: ~2KB\n\n\n3. **Model File Not Found**: Retrain the model\n   ```bash\n   python model/train.py\n\n## 📚 References\n\n- [Scikit-learn Decision Trees](https://scikit-learn.org/stable/modules/tree.html)\n- [FastAPI Documentation](https://fastapi.tiangolo.com/)\n- [Azure Functions Python Guide](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python)\n\n## 🏷️ Tags\n\n`machine-learning` `fastapi` `azure-functions` `docker` `iris-dataset` `decision-tree` `rest-api` `python` `scikit-learn`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuday160386%2Fml-model-as-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuday160386%2Fml-model-as-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuday160386%2Fml-model-as-rest-api/lists"}