Single logo
  • Courses
  • Blog
  • About
Join for freeJoin free
Machine Learning
  • First Look at a Dataset: 6 Checks Before You Plot or Model
  • Plotting Distributions with seaborn: Histograms, KDE, Counts and log1p
  • Scatter Plots and Pair Plots: See How Two Columns Relate
  • Finding Outliers: Box Plots, Violin Plots and the IQR Rule
  • Correlation and Heatmaps: Covariance, df.corr() and What They Miss
  • Train-Test Split and Data Leakage: Split First, Learn After
  • Handling Missing Data: Count the Blanks, Then Fill Them with SimpleImputer
  • Encoding Categorical Data: OrdinalEncoder, OneHotEncoder and LabelEncoder
  • Feature Scaling: StandardScaler, MinMaxScaler and Which Models Care
  • Pipelines and ColumnTransformer: All Preprocessing and the Model in One Object
  • Feature Selection and the Curse of Dimensionality: Keep the Columns That Matter
  • Project: Preprocess Rain in Australia from Raw CSV to Model-Ready Data
    Regression
    • Linear Regression and the Cost Function: Draw a Line, Score It
    • Gradient Descent Explained: Feel the Slope, Step Downhill
    • Linear Regression in scikit-learn: Fit, Predict and Read the Price Tags
    • Regression Metrics: MAE, RMSE, R-squared and the Baseline to Beat
    • Polynomial Regression, Overfitting and Underfitting: Bend the Line, Watch the Test Score
    • Regularisation with Ridge and Lasso: Put a Price on Big Weights
    Classification and Evaluation
    • Logistic Regression and the Sigmoid: Score, Squash, Decide
    • Logistic Regression in scikit-learn: predict, predict_proba and Softmax
    • Why Accuracy Lies: The Confusion Matrix, Baselines and Type I/II Errors
    • Precision, Recall and F1 Score: Two Questions and One Balance
    • ROC Curve, AUC and Choosing a Classification Threshold
    • Handling Imbalanced Data: class_weight, SMOTE and the Resampling Leak
    • Cross-Validation: KFold, StratifiedKFold, cross_val_score and cross_validate
    Classic Algorithms
    • K-Nearest Neighbours (KNN): Distance, k and Why Scaling Is a Must
    • Naive Bayes: Prior Times Likelihood, a Spam Filter by Hand and GaussianNB
    • Support Vector Machines (SVM): The Widest Road, C, Kernels and gamma
    • Decision Trees: Gini, max_depth and Feature Importances on Rain in Australia
    • Bagging and Random Forest: Many Shaky Trees, One Steady Answer
    • Boosting: Residuals by Hand, AdaBoost, Gradient Boosting and XGBoost
    • Voting and Stacking: Does a Team of Models Beat the Best One?
    Model Selection and Tuning
    • Hyperparameter Tuning with GridSearchCV and RandomizedSearchCV
    • Which Features Matter? Feature Importances, Permutation Importance and SHAP
    • Project: The Classification Master Template, from Raw CSV to a Saved Model
    • K-Means Clustering: Find Groups in Data With No Labels
    • Choosing k for K-Means: the Elbow Method and the Silhouette Score
    • Hierarchical Clustering and DBSCAN: Dendrograms, Linkage, eps and Noise
    • Dimensionality Reduction with PCA: 13 Columns Down to 2
    • Association Rules and Market Basket Analysis: Support, Confidence, Lift and Apriori
    • Recommender Systems: Item-Based Collaborative Filtering with Cosine Similarity
    • Bag of Words with CountVectorizer: Turn Text into Word Counts
    • TF-IDF with TfidfVectorizer: Common Words Fade, Rare Words Speak
    • Build a Text Classifier with TF-IDF and a Pipeline: Naive Bayes vs LinearSVC
    • Why Neural Networks: Pixels, One Neuron and Layers
    • The Forward Pass and Activation Functions: ReLU, Sigmoid, Tanh and Softmax
    • Loss and Backpropagation: How Wrong, and Who Is to Blame
    • The Training Loop: Epochs, Mini-Batches, Learning Rate and Optimisers
    • Your First Neural Network with Keras: MNIST Digits at 97.7%
    • The Same Network in PyTorch: DataLoader, nn.Module and the Five-Line Training Loop
    • Convolutional Neural Networks (CNN) Basics: Filters, Feature Maps and Pooling
    • Embeddings: Words as Vectors, Cosine Similarity and nn.Embedding
    • Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
    • Dropout, Early Stopping and Batch Norm: Judge Each One by the Validation Curve
    • Transfer Learning on Images: A Frozen ResNet-18, a Small Head and an Honest Baseline
    • Attention Explained Without the Maths: Query, Key, Value and the Word "it"
    • Transformer Building Blocks in PyTorch: Follow the Shapes Through Attention and a Block
    • Pretrained Models from Hugging Face: A Sentiment Pipeline and Sentence Embeddings on a CPU
    • Loading a Language Model and Running Inference: Download, Load, Tokenize, Generate
    • Model Size and Memory: Parameters x Bytes, Quantization, and Where to Run a Model
    • Training on a GPU: Mixed Precision, Gradient Accumulation and Checkpoints That Really Resume
    • When NOT to Fine-Tune: A Decision Tree of Prompt, RAG, Tools, Then Fine-Tuning
    • Full Fine-Tuning vs LoRA vs QLoRA: What Each One Changes and What It Costs
    • LoRA Fine-Tune of a Tiny Model: Teach SmolLM2-135M Your House Style on a CPU
    • Knowledge Distillation: Teach a Model 100 Times Smaller From a Teacher's Soft Labels
    • Serving Open Models: Continuous Batching, vLLM and Cold Starts
      Engineering Basics
      • Python Virtual Environments: One Project, One Toolbox
      • Git and GitHub Fundamentals: Commits, Branches, Push and Pull
      • Testing a FastAPI App with pytest: Three Small Tests
      • Config and Logging Instead of Hard-Coded Values in ML Training
      • SQL Essentials for Python: SELECT, WHERE, JOIN and GROUP BY
      Data and Features in Production
      • Time Splits and Group Splits: Make the Split Match How the Model Is Used
      • Time Series Basics: Lags, Rolling Windows and Walk-Forward Backtesting
      • Feature Engineering Patterns, Each One Tested: Date Parts, Differences, Windows and Target Encoding
      • Point-in-Time Correctness: Join Features as of Each Event with merge_asof
      • Data Validation and Schema Checks: Stop Bad Input Before It Reaches the Model
      • Training-Serving Skew: Same Model, Different Inputs, and How to Detect It
      • Feature Stores: Offline and Online Stores, and When You Actually Need One
      • Data Versioning with DVC: Tie Every Model to the Exact Data That Trained It
      Experiments and Model Quality
      • MLOps in One Picture: Code, Data, Model and the Lifecycle Loop
      • Experiment Tracking with MLflow: Log Params, Metrics and the Model, Then Compare Runs
      • MLflow Model Registry Aliases: Serve the Champion, Ship a New Version and Roll Back in One Line
      • The Cost of Being Wrong: Baselines, a Price per Mistake and the Cheapest Threshold
      • Probability Calibration: Can You Trust the 0.8? Reliability Curves, Platt and Isotonic
      • Slice Evaluation and Fairness Checks: Score the Model Group by Group
      Serving Models
      • Saving and Loading Models with joblib: One Pipeline, One File
      • FastAPI Hello World: Routes, uvicorn and the Free Swagger Page
      • Deploy a Machine Learning Model with FastAPI: POST /predict for a Saved Model
      • Docker Essentials for ML: Images, Containers and Volumes with a Model API
      • Containerising a Model API: A Dockerfile for FastAPI and scikit-learn, Line by Line
      • Online, Batch or Streaming? Picking the Serving Pattern for an ML Model
      • A Production FastAPI for an ML Model: Input Limits, /health, /ready and a Model Version
      • Batch Scoring a Million Rows: Chunks, a Run ID and a Safe Rerun
      • Latency Math: p50, p95, p99 and Why the Tail Reaches Your Users
      • Measuring Latency of an ML API: Timing Inside with OpenTelemetry, Outside with a Load Test and Locust
      • Making ML Inference Fast: ONNX, Micro-Batching and Quantisation, Measured
      • Sizing and Autoscaling an Inference Service: From One Replica to a Replica Count
      Pipelines, CI/CD and Cloud
      • The Training Pipeline as a DAG: Steps, Files, Retries and a Safe Rerun
      • Orchestrating ML Pipelines with Airflow: Schedule, Retries and Backfill
      • Retries and Backoff for Reliable Tasks: Retry What Heals, Wait Longer, Add Jitter, Set Limits
      • CI with GitHub Actions: Run the Tests and Build the Docker Image on Every Push
      • CI/CD for ML: A Quality Gate That Blocks a Weaker Model, Even When Every Test Passes
      • Which Cloud for What: AWS, Azure, Google Cloud, GPU Clouds, Edge and Platforms
      • IaaS, PaaS, Containers or Serverless? Choosing Where a Model API Runs
      • Kubernetes at a High Level: Pods, a Deployment and a Service for a Model API
      • Managed ML Platforms: What SageMaker, Vertex AI and Azure ML Give You, and Tie You To
      • Deploying a Model API to AWS: ECR, Secrets Manager, CloudWatch and Fargate, Then Teardown
      • Cloud Cost Thinking for ML: Size x Count x Hours x Rate, and Three Decisions Worth Ten Times
      Monitoring and Release
      • Monitoring Drift and Retraining: When a Model Gets Worse With No Code Change
      • Drift Detection in Code: PSI Bin by Bin, the KS Test, Evidently and a Measured Threshold
      • Shadow, Canary and Rollback: Releasing a New Model Without Betting Everything on It
      • A/B Tests for Models: Did the New Model Make Things Better for People?
      • When Labels Arrive Weeks Late: What to Watch Before You Can Grade the Model
      • Retraining Triggers: Schedule, Drift and Performance, Wired to One Retrain Pipeline
      • The User Feedback Loop: Why Thumbs Up Isn't the Truth, and What a Small Random Review Adds
      • Debugging a Model in Production: A Four-Step Runbook, Cheap Checks First
      • Project: Car Price Predictor End to End, from CSV to a FastAPI Price API
      1. Blog
      2. /
      3. Machine Learning
      4. /
      5. MLOps and Production ML

      MLflow Model Registry Aliases: Serve the Champion, Ship a New Version and Roll Back in One Line

      Ship a new model without touching the API: an MLflow alias called champion points at a registry version, a FastAPI service loads whatever it points at, version 2 goes live by moving the label, and one command rolls it back to version 1.

      Chaand Sheikh

      ·27 November 2026Experiments and Model Quality

      What you will learn

      • Load a registered model by alias (@champion) instead of a fixed version number
      • Explain why aliases replace the deprecated registry stages
      • Make a FastAPI service load the champion at start-up and report its version in every answer
      • Promote a new version and roll it back by moving the alias, with no code change

      Before you start

      • Experiment Tracking with MLflow
      • Deploy a Machine Learning Model with FastAPI

      In Experiment Tracking with MLflow we loaded a model by its number: models:/ticket-priority/1. That works, but the number lives in your code. A new model means editing the code, testing it and shipping it again.

      This article fixes that. We'll ship a new model without changing the API, and if the new model turns out badly, we'll take it back with one line. Same ticket-priority project, same synthetic tickets, MLflow 3.17.2.

      A hotel key desk

      Picture a hotel. The staff ask the key desk for room 12's key. The desk looks at its board and hands over key A.

      Now the lock gets changed. The desk updates its board to key B. The staff ask in exactly the same way and get the new key. They never learn a key number. And if key B jams? The desk changes one entry on the board, back to key A.

      Room 12 is our champion, the desk is the registry, and a key is a model version. Change what the desk hands out, and nobody else has to change.

      Two ways to name a model

      A number names one model forever. An alias is a name you put on a version, and you can move it later. Today @champion means version 1; tomorrow it can mean version 2.

      load_and_predict.py accepts either form:

      """Load by number or by alias: python load_and_predict.py 1 or @champion"""
      import json
      import sys
      
      import mlflow.sklearn
      import pandas as pd
      
      import tracking
      
      tracking.setup()
      ref = sys.argv[1] if len(sys.argv) > 1 else "@champion"
      where = ref if ref.startswith("@") else f"/{ref}"
      uri = f"models:/{tracking.MODEL_NAME}{where}"
      model = mlflow.sklearn.load_model(uri)
      
      with open("ticket.json") as f:
          row = pd.DataFrame([json.load(f)])
      print(f"{uri}  p_high={model.predict_proba(row)[0, 1]:.3f}")

      Same ticket, loaded both ways:

      models:/ticket-priority/1  p_high=0.424
      models:/ticket-priority@champion  p_high=0.424

      0.424 both times. It's the same model.

      Stages are on the way out, aliases are in

      Many tutorials use stages: fixed boxes like Staging and Production, and a version moves from box to box. Calling that API on MLflow 3.17 gives a warning:

      FutureWarning: ``mlflow.tracking.client.MlflowClient.transition_model_version_stage`` is deprecated since 2.9.0. Model registry stages will be removed in a future major release.

      The stage call still runs, but new code should use aliases. You pick the name and put it on a version. Two rules:

      • One alias points at one version.
      • One version can wear several aliases.

      Put the label on version 1

      First, python register_best.py registers the best run as version 1 (C = 10, F1 0.6504). Then:

      """Point an alias at a version: python set_alias.py champion 2"""
      import sys
      
      from mlflow import MlflowClient
      
      import tracking
      
      tracking.setup()
      alias, version = sys.argv[1], sys.argv[2]
      client = MlflowClient()
      client.set_registered_model_alias(tracking.MODEL_NAME, alias, version)
      print(f"{alias} -> version {version}")
      python set_alias.py champion 1
      champion -> version 1
      MLflow registered model page for ticket-priority with one version, which carries the alias @champion in the Aliases column.
      The champion label sits on version 1 in the MLflow registry.

      What did that do? Inside MLflow's database it's one row in a table: model name, alias, version number.

      [('ticket-priority', 'champion', 1)]

      An alias is one row. The model itself isn't touched.

      The service asks for the champion at start-up

      Now the API. FastAPI itself is covered in Deploy a Machine Learning Model with FastAPI; here we only care about how the model gets picked.

      """Serve whichever version the champion alias points at."""
      import logging
      
      import mlflow.sklearn
      import pandas as pd
      from fastapi import FastAPI
      from mlflow import MlflowClient
      from pydantic import BaseModel
      
      import tracking
      
      log = logging.getLogger("uvicorn.error")
      tracking.setup()
      client = MlflowClient()
      app = FastAPI(title="Ticket Priority")
      
      
      def load_champion():
          name = tracking.MODEL_NAME
          version = client.get_model_version_by_alias(name, "champion").version
          model = mlflow.sklearn.load_model(f"models:/{name}/{version}")
          log.info("loaded champion, version %s", version)
          return model, version
      
      
      current = load_champion()   # runs once, when the server starts
      
      
      class Ticket(BaseModel):
          channel: str
          customer_tier: str
          product_area: str
          words: int
          has_attachment: int
          previous_tickets: int
          hour: int
          sentiment: float
      
      
      @app.post("/predict")
      def predict(ticket: Ticket):
          model, version = current
          row = pd.DataFrame([ticket.model_dump()])
          p_high = float(model.predict_proba(row)[0, 1])
          return {"priority": "high" if p_high >= 0.5 else "low",
                  "p_high": round(p_high, 3), "version": version}
      
      
      @app.post("/reload")
      def reload():
          global current
          current = load_champion()
          return {"version": current[1]}

      load_champion asks the registry get_model_version_by_alias: champion goes in, the number 1 comes back. Then it loads that exact number. We ask once, so the version we report is always the one we loaded. Both are kept together in current.

      python -m uvicorn app:app --port 8000
      INFO:     loaded champion, version 1
      INFO:     Started server process [34100]
      INFO:     Waiting for application startup.
      INFO:     Application startup complete.

      And if nobody has set the alias yet? The server stops at start-up:

      mlflow.exceptions.MlflowException: Registered model alias champion not found.

      It fails loudly, and that's good. The code says champion; it never says a number.

      Every answer names its version

      python ask.py posts a borderline ticket from ticket.json to /predict:

      {"priority":"low","p_high":0.424,"version":1}

      0.424 is under one half, so it's low. Look at what comes back: the priority, the probability and the version. If an answer ever looks wrong, you know exactly which model gave it.

      Version 2 arrives, and the API doesn't notice

      train_candidate.py trains a candidate with the same settings, except a high ticket counts double while it learns: class_weight={0: 1, 1: 2}.

      high x2  accuracy=0.6420  f1=0.6832

      F1 rises from 0.6504 to 0.6832. Run register_best.py again and it becomes version 2:

      best run: logreg-high-x2  C=10.0  f1=0.6832
      registered 'ticket-priority' as version 2

      The label stays on version 1, and the API still answers "version":1. Registering a model deploys nothing. A new version only sits on the shelf until you move the label.

      Move the label, then reload

      python set_alias.py champion 2
      python ask.py
      champion -> version 2
      {"priority":"low","p_high":0.424,"version":1}

      No code file changed, but the answer still says version 1. Why? The server loaded its model at start-up and is holding it in memory. It's the staff member with yesterday's key in their pocket. It has to go back to the desk:

      python ask.py reload
      python ask.py
      {"version":2}
      {"priority":"high","p_high":0.6,"version":2}
      MLflow registered model page for ticket-priority with two versions. The newer version carries the alias @champion; the older version has no alias.
      After set_alias.py champion 2, the label sits on version 2. Version 1 is still on the shelf.

      Same code, same process, a new model: the same ticket now says high, 0.6, version 2. A restart does the same job; it took several seconds here, against under a second for /reload. Our /reload has no login, so in a real service, protect it or just restart.

      Rollback is one line

      Now suppose the support team comes back: nearly everything is marked urgent. Load both versions by number and score them on the same test tickets:

      python compare_versions.py 1 2
      really high in the test set: 45.8%
      version 1  accuracy=0.6840  f1=0.6504  flagged high=44.6%
      version 2  accuracy=0.6420  f1=0.6832  flagged high=67.2%

      About 46% of tickets are really high. Version 1 flags 45%, version 2 flags 67%. Its F1 went up, but its accuracy fell. And it isn't luck: across 20 data splits, the weighting flagged more tickets in 20 of 20, raised F1 in 19 and lowered accuracy in 19. F1 likes it; the support queue doesn't.

      python set_alias.py champion 1
      python ask.py reload
      python ask.py
      champion -> version 1
      {"version":1}
      {"priority":"low","p_high":0.424,"version":1}

      Nothing retrained, no code touched, and version 2 is still on the shelf if you want it later.

      Common mistakes

      • Hard-coding a version number in the service. Every new model becomes a code change. Ask for an alias.
      • Expecting registration to deploy. It doesn't. Only moving the alias changes what the service will load.
      • Forgetting the running process. A server that loaded at start-up keeps its old model until it reloads or restarts.
      • Leaving /reload open. Anyone who can reach it can force the service to re-read the alias. Protect it, or restart instead.
      • Writing new code with stages. They're deprecated since MLflow 2.9.0.

      Recap

      StepCommandResult
      Label version 1set_alias.py champion 1API serves v1, ticket low 0.424
      Register a candidatetrain_candidate.py, register_best.pyv2 on the shelf, API still v1
      Promoteset_alias.py champion 2 + reloadticket high 0.6, version 2
      Roll backset_alias.py champion 1 + reloadticket low 0.424, version 1

      A version is a number that stays fixed. The champion is a label that moves. Ship a name, not a number.

      Try it yourself

      Point a second alias, challenger, at version 2 with python set_alias.py challenger 2, then load it with python load_and_predict.py @challenger. Open the registry page and check that version 1 still wears @champion.

      Built this? Share your solution in the StudyEasy AI Community.

      Join free on Skool →
      ← Previous
      Experiment Tracking with MLflow: Log Params, Metrics and the Model, Then Compare Runs
      Next →
      The Cost of Being Wrong: Baselines, a Price per Mistake and the Cheapest Threshold
      Single logo

      StudyEasy AI Community

      Hosted onSkool

      Learn AI engineering, share what you build, and connect with other learners.

      • Free resources: lesson files, notebooks and code

      • Ask questions and join engineering discussions

      • Meet real people learning and building with AI

      Join free on Skool
      Go deeper with a course

      Machine Learning Engineer: From First Model to ML Engineer

      Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (opens in a new tab)

      Related articles
      Python Virtual Environments: One Project, One Toolbox

      Why every Python project gets its own virtual environment: two projects that need different versions of requests, python -m venv .venv, activation, pip install and the PyCharm setting that activates it for you.

      Git and GitHub Fundamentals: Commits, Branches, Push and Pull

      The Git you use every day, on a tiny hello-ml project: commits as save points, the staging area, a branch merged with a fast-forward, then push, clone, pull and pull requests with a teammate.

      Testing a FastAPI App with pytest: Three Small Tests

      A tiny FastAPI app with a Hello World route and a name route that refuses numbers, three pytest tests that check it, and what happens when the validation is deleted by mistake.

      Config and Logging Instead of Hard-Coded Values in ML Training

      Take the hard-coded values out of a car price training script: one config.toml read with tomllib, logging with levels and a run id on every line, and secrets read from the environment. Same RMSE, 2195, before and after.

      On this page
      • A hotel key desk
      • Two ways to name a model
      • Stages are on the way out, aliases are in
      • Put the label on version 1
      • The service asks for the champion at start-up
      • Every answer names its version
      • Version 2 arrives, and the API doesn't notice
      • Move the label, then reload
      • Rollback is one line
      • Common mistakes
      • Recap
      • Try it yourself
      Single logo

      StudyEasy AI Community

      Hosted onSkool

      Learn AI engineering, share what you build, and connect with other learners.

      • Free resources: lesson files, notebooks and code

      • Ask questions and join engineering discussions

      • Meet real people learning and building with AI

      Join free on Skool
      Go deeper with a course

      Machine Learning Engineer: From First Model to ML Engineer

      Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (opens in a new tab)

      Single logo

      Empowering Education, One Course at a Time

      About
      About usContact usFAQs
      Legal
      Terms of ServicePrivacy Policy

      © 2026 StudyEasy Organization. All rights reserved.