This is a comprehensive, modular tutorial covering all four core components of MLflow:
- MLflow Tracking - Experiment tracking and logging
- MLflow Projects - Reproducible ML code packaging
- MLflow Models - Standardized model packaging
- MLflow Model Registry - Model versioning and lifecycle management
mlflow_complete_tutorial/
│
├── 📄 README.md # Main documentation
├── 📄 QUICKSTART.md # Quick start guide
├── 📄 PROJECT_SUMMARY.md # This file
├── 📄 requirements.txt # Python dependencies
├── 📄 .gitignore # Git ignore rules
├── 📄 setup.sh # Setup script (executable)
│
├── 📁 MLflow Configuration
│ ├── MLproject # MLflow project definition
│ └── python_env.yaml # Python environment specification
│
├── 📁 Tutorial Components (Run in order)
│ ├── 1_tracking.py # Component 1: MLflow Tracking
│ ├── 2_projects.py # Component 2: MLflow Projects
│ ├── 3_models.py # Component 3: MLflow Models
│ └── 4_model_registry.py # Component 4: Model Registry
│
├── 📁 Utilities
│ ├── utils.py # Shared utility functions
│ └── run_all.py # Master script (runs all components)
│
└── 📁 data/ # Data directory (auto-generated datasets)
└── README.md
Duration: ~2-3 minutes
Features:
- ✅ Creating and managing experiments
- ✅ Logging parameters (hyperparameters)
- ✅ Logging metrics (accuracy, F1, etc.)
- ✅ Logging tags for organization
- ✅ Logging artifacts (plots, files, models)
- ✅ Nested runs for hyperparameter tuning
- ✅ Batch logging over epochs/iterations
- ✅ Custom artifact logging
Experiments Created:
- Basic_Tracking_Demo
- Hyperparameter_Tuning_Demo
- Batch_Logging_Demo
- Custom_Artifacts_Demo
Duration: ~3-4 minutes
Features:
- ✅ Project structure with MLproject file
- ✅ Parameterized execution
- ✅ Running projects programmatically
- ✅ Environment specification
- ✅ Multiple parameter combinations
- ✅ Reproducible runs
Experiments Created:
- MLflow_Projects_Demo
Duration: ~2-3 minutes
Features:
- ✅ Sklearn model saving and loading
- ✅ PyTorch model support
- ✅ Custom PyFunc models
- ✅ Model signatures
- ✅ Input examples
- ✅ Model metadata
- ✅ Batch and real-time inference
- ✅ Multiple model flavors
Experiments Created:
- MLflow_Models_Demo
Duration: ~2-3 minutes
Features:
- ✅ Model registration
- ✅ Model versioning (v1, v2, v3)
- ✅ Stage transitions (Staging → Production → Archived)
- ✅ Model descriptions and annotations
- ✅ Model tags
- ✅ Loading models by version/stage/alias
- ✅ Model comparison
- ✅ Model aliasing (champion/challenger)
Registered Models:
- classification_model (3 versions)
# Method 1: Using setup script (recommended)
./setup.sh
# Method 2: Manual setup
pip install -r requirements.txt# Run all components in sequence
python run_all.py
# Run individual components
python 1_tracking.py
python 2_projects.py
python 3_models.py
python 4_model_registry.py
# Run via MLflow Projects
mlflow run . -e main# Start MLflow UI (in separate terminal)
mlflow ui
# Then visit: http://localhost:5000After running the complete tutorial, you will have:
- 4 experiments with dozens of runs
- 100+ logged metrics
- 50+ logged parameters
- Multiple artifacts (plots, models, files)
- 3 registered model versions
- Models in different stages (Staging, Production, Archived)
- Models with descriptions and tags
- Multiple model flavors (sklearn, PyTorch, PyFunc)
- Confusion matrices
- Feature importance plots
- Training curves
- Classification reports
- Model files
- Configuration files
- MLflow 2.8.0+ - Core framework
- scikit-learn 1.3.0+ - Traditional ML models
- PyTorch 2.0.0+ - Deep learning models
- NumPy 1.24.0+ - Numerical computing
- Pandas 2.0.0+ - Data manipulation
- Matplotlib 3.7.0+ - Plotting
- Seaborn 0.12.0+ - Statistical visualization
After completing this tutorial, you will understand:
-
Experiment Tracking
- How to log and track ML experiments
- Best practices for parameter and metric logging
- Organizing experiments with tags and nested runs
-
Reproducibility
- Creating reproducible ML pipelines
- Environment management
- Parameterized execution
-
Model Management
- Packaging models in standard format
- Model signatures and validation
- Loading and serving models
-
Model Lifecycle
- Versioning models
- Managing deployment stages
- Model governance and comparison
- Always log everything - parameters, metrics, and artifacts
- Use meaningful experiment names for organization
- Add tags for better filtering and search
- Include model signatures for validation
- Provide input examples for testing
- Add descriptions to models and versions
- Use stages to manage deployment lifecycle
- Compare models before promoting to production
Extend the tutorial by:
-
Adding your own datasets
- Replace synthetic data with real datasets
- Implement custom data loaders
-
Trying different algorithms
- XGBoost, LightGBM, CatBoost
- Neural networks with TensorFlow
- Time series models
-
Adding more metrics
- ROC curves, PR curves
- Custom business metrics
- Model interpretability metrics
-
Implementing hyperparameter optimization
- Grid search
- Random search
- Bayesian optimization (Optuna, Hyperopt)
-
Setting up remote tracking
- PostgreSQL backend
- S3/Azure/GCS artifact storage
- Shared tracking server
This tutorial is designed for learning. Feel free to:
- Modify the code
- Add new examples
- Improve documentation
- Share with others
- All datasets are synthetically generated - no external data required
- The tutorial is self-contained - all dependencies in requirements.txt
- No GPU required - runs on CPU
- Modular design - each component is independent
- Production-ready concepts - patterns used in real ML projects
- Initial Setup: 5-10 minutes
- Component 1 (Tracking): 2-3 minutes
- Component 2 (Projects): 3-4 minutes
- Component 3 (Models): 2-3 minutes
- Component 4 (Registry): 2-3 minutes
- Total Tutorial Time: 15-25 minutes
- Complete the tutorial - Run all components
- Explore the MLflow UI - Visualize experiments and models
- Modify the code - Experiment with different parameters
- Apply to your projects - Integrate MLflow into your workflow
- Explore advanced features - Remote tracking, deployment, CI/CD
Happy Learning! 🚀
This tutorial provides a solid foundation for using MLflow in production ML workflows.