Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Step-by-Step: Install & Run MLflow on Windows

Here’s a step-by-step guide to install and run MLflow on Windows, covering setup, UI launch, and test tracking. This works on Windows 10/11 with Python ≥ 3.8.


✅ Step-by-Step: Install & Run MLflow on Windows


🧰 Step 1: Install Python (if not already installed)

MLflow works best with Python 3.8–3.11.


💡 Step 2 (Recommended): Create a Virtual Environment

Open Command Prompt or PowerShell and run:

python -m venv mlflow-env
.\mlflow-env\Scripts\activate

This isolates dependencies for MLflow.


📦 Step 3: Upgrade pip

Still inside the virtual environment:

python -m pip install --upgrade pip

🚀 Step 4: Install MLflow

Run:

pip install mlflow

Verify it installed:

mlflow --version

You should see something like:

mlflow, version 2.21.3
Code language: CSS (css)

🌐 Step 5: Launch the MLflow Tracking UI

Run:

mlflow ui
or
start mlflow ui

This will start a local server at:

http://127.0.0.1:5000
Code language: JavaScript (javascript)

Visit this URL in your browser to access the MLflow UI.


🧪 Step 6: Run a Test MLflow Tracking Script

Save the following as test_mlflow.py:

import mlflow
import mlflow.sklearn
from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split

# 🔧 Set tracking URI to the running server
mlflow.set_tracking_uri("http://127.0.0.1:5000")

# Load dataset
data = load_diabetes()
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target)

# Enable autologging
mlflow.sklearn.autolog()

# Start tracking
with mlflow.start_run():
    model = RandomForestRegressor()
    model.fit(X_train, y_train)
    score = model.score(X_test, y_test)
    print("Model score:", score)
Code language: PHP (php)

Run the script:

This opens a new command prompt window for the UI, leaving your current terminal free.

Then in the same terminal:

python mlflow_test.py

Now go back to your MLflow UI (http://127.0.0.1:5000) and you will see the run logged.

✅ What Just Happened:

  • ✅ Your ML model trained (RandomForestRegressor)
  • ✅ The model’s score was printed: 0.3752
  • ✅ The run was logged to MLflow’s tracking server at http://127.0.0.1:5000
  • ✅ A run name like learned-hound-363 was auto-generated
  • ✅ The script output gave you two links:

📁 Step 7: Where is the data saved?

MLflow creates a folder named:

mlruns/

This contains all experiment logs and metrics.


🧼 Optional Cleanup

To stop the MLflow UI:

  • Press Ctrl + C in the terminal

To deactivate the virtual environment:

deactivate

🛠️ Troubleshooting Tips

IssueSolution
mlflow: command not foundMake sure you’re in the virtual environment. Activate with .\mlflow-env\Scripts\activate
Port 5000 busyRun mlflow ui --port 5001
UI not openingUse full URL http://127.0.0.1:5000 in your browser
Python 3.13 issuesDowngrade to Python 3.10 or 3.11 for stability

One Code

import mlflow
import mlflow.sklearn
from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split

# 🔧 Set tracking URI to the running server
mlflow.set_tracking_uri("http://127.0.0.1:5000")
mlflow.set_experiment("MyImprovedExperiment")

# Load dataset
data = load_diabetes()
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target)

# Enable autologging
mlflow.sklearn.autolog()

# Start tracking
with mlflow.start_run():
    model = RandomForestRegressor()
    model.fit(X_train, y_train)
    score = model.score(X_test, y_test)

    print("Model score:", score)

    # Optional: log manually with input example
    input_example = X_train[0:1]
    mlflow.sklearn.log_model(
        sk_model=model,
        artifact_path="model",
        input_example=input_example,
    )

mlflow.log_param("learning_rate", 0.1)
mlflow.log_metric("accuracy", 0.87)
mlflow.sklearn.log_model(model, "my_model")
Code language: PHP (php)

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x