Training vs Inference — Complete Guide
Training vs Inference — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of ML.NET Tutorial on Toolliyo Academy.
On this page
ML.NET Tutorial · Lesson 18 of 100
Training vs Inference
Foundations → Models → NLP & advanced → MLOps
Foundations · 1 — Context & data · ~6 min · Module 2: Machine Learning Basics
What is this?
Training Fits a model from labeled data; inference Transforms/Predicts on new rows with a frozen model.
Why should you care?
AIPredict trains offline nightly; APIs only run inference for low latency.
See it live — copy this example
Use a .NET console or Web API project with Microsoft.ML. Run dotnet run after pasting.
// Training job
var model = pipeline.Fit(train);
ml.Model.Save(model, train.Schema, "fraud.zip");
// API inference
var loaded = ml.Model.Load("fraud.zip", out _);
var pred = ml.Model.CreatePredictionEngine<Tx, Score>(loaded).Predict(tx);
What happened?
- Never Fit inside a customer request.
- Warm PredictionEngine or use PredictionEnginePool in ASP.NET Core.
Practice next
- Separate TrainWorker vs Api projects.
- Save zip from worker.
- API only Load/Predict.
- Time Fit vs Predict once.
- Document model path env var.
Remember
Train offline. Infer online. Pool engines in web.
AIPredict train/infer split
Worker writes fraud.zip; API scores.
Outcome: p95 stays milliseconds.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!