{"id":13736925,"url":"https://github.com/ashishpatel26/MLflow_End_to_End_Example","last_synced_at":"2025-05-08T13:31:56.325Z","repository":{"id":37362100,"uuid":"503358716","full_name":"ashishpatel26/MLflow_End_to_End_Example","owner":"ashishpatel26","description":"MLflow is Open source platform for the machine learning lifecycle so here you can learn MLflow End to End Example with Prediction.","archived":false,"fork":false,"pushed_at":"2022-06-14T13:20:52.000Z","size":1641,"stargazers_count":14,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-04T03:07:37.855Z","etag":null,"topics":["mlflow","mlflow-example","mlflow-tracking","scikit-learn","xgboost"],"latest_commit_sha":null,"homepage":"https://mlflow.org/docs/latest/index.html","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/ashishpatel26.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}},"created_at":"2022-06-14T12:52:53.000Z","updated_at":"2024-05-06T15:06:07.000Z","dependencies_parsed_at":"2022-07-20T12:02:28.356Z","dependency_job_id":null,"html_url":"https://github.com/ashishpatel26/MLflow_End_to_End_Example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FMLflow_End_to_End_Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FMLflow_End_to_End_Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FMLflow_End_to_End_Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashishpatel26%2FMLflow_End_to_End_Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashishpatel26","download_url":"https://codeload.github.com/ashishpatel26/MLflow_End_to_End_Example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224737431,"owners_count":17361345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["mlflow","mlflow-example","mlflow-tracking","scikit-learn","xgboost"],"created_at":"2024-08-03T03:01:31.569Z","updated_at":"2024-11-15T05:30:52.329Z","avatar_url":"https://github.com/ashishpatel26.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"### MLFlow End to End Tutorial\n---\n![](https://databricks.com/wp-content/uploads/2018/06/mlflow.png)\n\n### **What is MLFlow?**\n---\n* **MLflow** is opensource platform to Manage the ML Life Cycle. \n* It includes **experimentation, reproducibility, deployment and central model registry.**\n* Advantage of Use **MLFlow** is **Transparency** and **Standardization**.\n* It helps you to **train, reuse** and **deploy the model**.\n\n![](https://databricks.com/wp-content/uploads/2020/06/blog-mlflow-model-1.png)\n\n### MLFlow Setup\n---\n1. Installation of **MLflow**.\n\n```bash\npip install mlflow\n```\n\n2. Once you will install with this now time to setup **Central Repository Database** where we will log all our tracking information and also will create the artifacts folder to store our models and its relevant information.\n\n```bash\n# Terminal Command\nmlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifacts --host 0.0.0.0 \n```\nor\n```bash\nmlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifacts --host 127.0.0.1 --port 5000\n```\n![](https://raw.githubusercontent.com/ashishpatel26/MLflow_End_to_End_Example/main/images/step1.jpg)\n\n\u003e **Output**\n\n![](https://raw.githubusercontent.com/ashishpatel26/MLflow_End_to_End_Example/main/images/step1_result.jpg)\n\n\u003e This Command create the **`mlflow.db`** and **`artifacts`** folder.\n\n### Open MLFLOW UI\n\n---\n\n```bash\nmlflow ui\n```\n\n![](https://raw.githubusercontent.com/ashishpatel26/MLflow_End_to_End_Example/main/images/open_mlflow.jpg)\n\n### MLFLOW UI LOOKS LIKE\n\n---\n\n![](https://raw.githubusercontent.com/ashishpatel26/MLflow_End_to_End_Example/main/images/mlflowui.jpg)\n\n### MLflow Tracking\n---\n* **MLflow** Tracking is an **API** and **UI** for **Logging Parameter, Code Versions, Metrics, and Output files.**\n\n##### Set Tracking URI and Create Experiment\n\n* We have to create the notebook for tracking server will run in. and we have to set the tracking URI. In our example, `localost:5000` is the tracking URI but you can setup any other tracking host and port in the `set_tracking_uri` function call. \n* Initially we have to default experiment created which you can get with `get_experiment` function call.\n\n⭐ **`mlflow.py`**\n\n---\n\n```python\nexperiment_id = mlflow.create_experiment(\"my_experiment\")\nexperiment = mlflow.get_experiment(experiment_id)\n```\n\n```python\nmlflow.set_tracking_uri(\"http://localhost:5000\")\nexperiment = mlflow.get_experiment('0')\nprint(\"Name: {}\".format(experiment.name))\nprint(\"Artifact Location: {}\".format(experiment.artifact_location))\nprint(\"Life Cycle Stage: {}\".format(experiment.lifecycle_stage))\nprint(\"Experiement ID: {}\".format(experiment.experiment_id))\n```\n### **🤝 Prepare the Notebook with ML Case study**\n\n---\n\u003e For Experiment Run Notebook, we have to create the notebook with the following steps.\n\n| Notebook | Link |\n|--|:--:|\n|Notebook| [Open](Notebook.ipynb)|\n\n**Notebook Flow**\n\n---\n\n![](https://raw.githubusercontent.com/ashishpatel26/MLflow_End_to_End_Example/main/images/flow.png)\n\n### MLFlow Model Flavors\n\n---\n\n\u003e The model can be used with tools that support either the `sklearn` or `python_function` model flavors.\n\n![](https://miro.medium.com/max/700/1*_RIJnhAi-Lpbith39-gRjg.png)\n\n### Diverse Platform\n\n---\n\n\u003e MLflow provides tools to deploy many common model types to diverse platforms.\n\n![](https://miro.medium.com/max/700/1*ZUYhQ-lKlWRiwLFYHMTfcw.png)\n\n\n\n### Experiments\n\n---\n\n![](https://raw.githubusercontent.com/ashishpatel26/MLflow_End_to_End_Example/main/images/experiments.jpg)\n\n### Final Model Prediction from Staging Code\n\n---\n\n```python\n# Predict with MLflow Model\nprint(\"Predict with MLflow Model:\")\n# models:///XGBoost_Model/{Stage} -- Stage Contains Two Stage 1. Staging 2. Production(Current)\nmodel = mlflow.xgboost.load_model(\"models:///XGBoost_Model/Production\")\nprint(\"=\"*50)\nprint(\"Model:\\n\", model)\nprint(\"=\"*50)\nprediction = model.predict(X_test)\n# print(\"Prediction.type:\", type(prediction))\n# print(\"=\"*50)\n# print(\"Prediction.shape:\", prediction.shape)\n# print(\"=\"*50)\nprint(\"Prediction:\\n\", prediction)\nprint(\"Prediction Done.\")\n```\n\n---\n\n### Thanks for Reading 👨‍💻👩‍💻🧑‍💻\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashishpatel26%2FMLflow_End_to_End_Example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashishpatel26%2FMLflow_End_to_End_Example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashishpatel26%2FMLflow_End_to_End_Example/lists"}