Skip to content

MLflow is Open source platform for the machine learning lifecycle so here you can learn MLflow End to End Example with Prediction.

Notifications You must be signed in to change notification settings

ashishpatel26/MLflow_End_to_End_Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MLFlow End to End Tutorial


What is MLFlow?


  • MLflow is opensource platform to Manage the ML Life Cycle.
  • It includes experimentation, reproducibility, deployment and central model registry.
  • Advantage of Use MLFlow is Transparency and Standardization.
  • It helps you to train, reuse and deploy the model.

MLFlow Setup


  1. Installation of MLflow.
pip install mlflow
  1. 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.
# Terminal Command
mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifacts --host 0.0.0.0 

or

mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifacts --host 127.0.0.1 --port 5000

Output

This Command create the mlflow.db and artifacts folder.

Open MLFLOW UI


mlflow ui

MLFLOW UI LOOKS LIKE


MLflow Tracking


  • MLflow Tracking is an API and UI for Logging Parameter, Code Versions, Metrics, and Output files.
Set Tracking URI and Create Experiment
  • 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.
  • Initially we have to default experiment created which you can get with get_experiment function call.

mlflow.py


experiment_id = mlflow.create_experiment("my_experiment")
experiment = mlflow.get_experiment(experiment_id)
mlflow.set_tracking_uri("http://localhost:5000")
experiment = mlflow.get_experiment('0')
print("Name: {}".format(experiment.name))
print("Artifact Location: {}".format(experiment.artifact_location))
print("Life Cycle Stage: {}".format(experiment.lifecycle_stage))
print("Experiement ID: {}".format(experiment.experiment_id))

🤝 Prepare the Notebook with ML Case study


For Experiment Run Notebook, we have to create the notebook with the following steps.

Notebook Link
Notebook Open

Notebook Flow


MLFlow Model Flavors


The model can be used with tools that support either the sklearn or python_function model flavors.

Diverse Platform


MLflow provides tools to deploy many common model types to diverse platforms.

Experiments


Final Model Prediction from Staging Code


# Predict with MLflow Model
print("Predict with MLflow Model:")
# models:///XGBoost_Model/{Stage} -- Stage Contains Two Stage 1. Staging 2. Production(Current)
model = mlflow.xgboost.load_model("models:///XGBoost_Model/Production")
print("="*50)
print("Model:\n", model)
print("="*50)
prediction = model.predict(X_test)
# print("Prediction.type:", type(prediction))
# print("="*50)
# print("Prediction.shape:", prediction.shape)
# print("="*50)
print("Prediction:\n", prediction)
print("Prediction Done.")

Thanks for Reading 👨‍💻👩‍💻🧑‍💻

About

MLflow is Open source platform for the machine learning lifecycle so here you can learn MLflow End to End Example with Prediction.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published