Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MLflow Experiment Tracking Example: Wine Quality Prediction

This project is a basic example of a machine learning workflow using MLflow to track experiments. The script trains an ElasticNet regression model from scikit-learn to predict the quality of red wine based on its chemical properties.

Overview

The example.py script performs the following steps:

  1. Downloads the Wine Quality dataset from a public URL.
  2. Splits the data into training and testing sets.
  3. Trains an ElasticNet model.
  4. Evaluates the model using RMSE, MAE, and R2 metrics.
  5. Uses MLflow to log the following information for each run:
    • Hyperparameters: alpha and l1_ratio.
    • Metrics: RMSE, MAE, and R2.
    • Artifacts: The trained scikit-learn model itself.

Prerequisites

Before you begin, ensure you have Python and Conda installed.

  1. Create and Activate a Conda Environment:

    # Create a new environment named 'mlops-venv' with Python 3.8 (or your preferred version)
    conda create --name mlops-venv python=3.8 -y
    
    # Activate the environment
    conda activate mlops-venv
  2. Install Required Libraries:

    pip install mlflow pandas scikit-learn numpy

How to Run

You can run the script with default hyperparameters or provide custom values via the command line.

  1. Run with Default Parameters (alpha=0.5, l1_ratio=0.5):

    python example.py
  2. Run with Custom Parameters: Provide alpha and l1_ratio as command-line arguments.

    # Example: run with alpha=0.8 and l1_ratio=0.7
    python example.py 0.8 0.7

Viewing the Results

After running the script, a new directory named mlruns will be created. This directory contains all the information about your experiment runs.

To visualize the results, use the MLflow UI.

  1. Launch the MLflow UI: From the same directory that contains mlruns, run the following command:

    mlflow ui
  2. Open Your Browser: Navigate to http://127.0.0.1:5000 (or the address shown in your terminal).

Here, you can compare different runs, view parameters, metrics, and download the saved models from

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages