Agentic AI DevOps: ML Basics
Recap of the previous session
- Machine learning finds a pattern in historical data, turns it into an algorithm (math), and uses it to predict.
- Prediction systems give one answer (loan approved or rejected). Recommendation systems rank many answers by weight.
- Structured data is rows and columns. Unstructured data is images, audio, video and text.
- Training learns from data that has the answers. Inference predicts on new data. The result of training is the ML model.
In this session
- Two kinds of ML problems: classification and regression
- Features, the target and the model
- How a machine learns: guess a line, measure the loss, adjust (the salary story)
- The model as an equation:
y = m·x + b - Gradient descent and epochs
- Many features: one weight per feature
- Training vs. inference: where quality is decided
- Classification: the sigmoid and the 0.5 decision boundary
In one sentence: a machine learning model is a simple equation whose numbers were found by trial and error against real data.
Why learn this? These are the building blocks of every AI system. They are not used directly when you build agents, but they explain what happens under the hood, and they are the base for the MLOps part of the course.
1. Two kinds of ML problems

Classification examples: email, card transaction, news article, image, audio, video
Classification: “Which bucket does this belong to?”
The answer comes from a fixed list of categories, called classes.
| Example | Classes | Type |
|---|---|---|
| Is this email spam? | Spam / Not spam | Binary (2 classes) |
| Is this card transaction fraud? | Fraud / Not fraud | Binary |
| Which topic is this article about? | Business / International / Finance / Banking | Multi-class (3 or more) |
| Is this image a car or a bus? | Car / Bus | Binary (the data is unstructured, but it is still classification) |
Regression: “What is the number?”
The answer is a continuous number, not a pick from a list: a house price (700k, 1000k, 850k, any value), a salary, or the speech rate in an audio clip (words per minute).
Quick test: can I list every possible answer in advance? Yes: classification. No, it is a number on a scale: regression.
Why it matters: the type of problem decides how you train the model, so identify it first.
2. Features, target and the model
Training data has two parts:
- Features (inputs): what describes the thing. For a house: area, bedrooms.
- Target (label): the answer you want to predict. For a house: the price.
| Phase | The model gets | It produces |
|---|---|---|
| Training | Features and target (it learns from the answers) | A trained model |
| Inference | Features only | A predicted target |
In practice you write a Python program (the ML program), give it the dataset, and run it. It learns the pattern and saves what it learned as an artifact. That artifact is the ML model.
Analogy: a Java build gives you a
.jarfile, one file that carries the logic. ML training gives you a model file.
- A model works only for the problem it was trained on. A house-price model cannot predict loan approvals: one problem, one model.
- Prediction quality depends on the quality of the data and of the training. No model is 100% correct.
3. How does a machine learn? The salary story

Linear regression: salary from experience
The data: years of experience and salary (in thousands).
| Experience | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Salary | 10 | 20 | 30 | 40 | 50 | 60 |
The question: what is the salary for 8 years?
Your gut says 80. A machine cannot “just see it”. It has to prove it with math. It works in three steps:
- Guess a line. Plot the data and draw a random straight line through it. Read predictions off the line.
- Measure the error. Compare each prediction with the real answer. The gap is the error (delta). For example, the real salary at 6 years is 60 but the line says 80, so the error is 20. Add up the errors for all rows and you get the loss: one number that says how wrong the model is. (In practice each error is squared first so that positive and negative errors do not cancel each other.)
- Loss = 0: the predictions match reality.
- Loss > 0: the line is wrong.
- Adjust and repeat. Try a different line, compute the predictions and the loss again, and keep going until the loss is zero or as close to zero as possible.
Analogy: exam preparation. Cover the answers, try the question, then uncover the real answer and compare. A mismatch tells you to study again. ML training is exactly this loop.
4. Turning the line into math: y = m·x + b
A program cannot look at a graph, so the line becomes an equation:
y = m × x + b
| Symbol | Name | Meaning |
|---|---|---|
y |
Target | What you predict (salary) |
x |
Input feature | What you know (experience) |
m |
Slope (also called coefficient or weight) | How much y changes when x increases by 1 |
b |
Bias (also called intercept) | The value of y when x is 0 |
For this data, take any two points: slope = (60 − 50) / (6 − 5) = 10. The line that passes through the origin has b = 0. Changing b moves the line up or down, which changes the predictions and the loss.
So the best combination here is m = 10, b = 0, giving zero loss:
salary = 10 × experience + 0
8 years → 10 × 8 + 0 = 80
10 years → 10 × 10 + 0 = 100
m, b = 10, 0 # the learned parameters
def predict(x):
return m * x + b
print(predict(8)) # 80
m and b are the learnable parameters: they are found during training and applied later during inference. Training saves them inside the model.
5. Gradient descent and epochs
How does the program find the best m and b? It starts with a random guess, measures the loss, adjusts the parameters a little, and repeats. This technique is called gradient descent.
- Epoch: one iteration of this loop. If it takes ten rounds of adjusting to reach a minimal loss, that is ten epochs.
- You cannot know in advance how many epochs are needed. The goal is a loss of zero, or as close to it as the data allows.
6. Many features: one weight per feature

Multiple linear regression: each feature gets its own weight
Salary depends on more than experience: education, projects, certifications. House prices depend on area and bedrooms, and also on things like nearby shops. Include in the dataset every input you think influences the target, because the model cannot learn from information it never sees.
The equation stays linear, but each feature gets its own weight:
y = w1·x1 + w2·x2 + w3·x3 + w4·x4 + b
- One weight per feature, and one bias for the whole dataset.
m(the math term) andw(the ML term, weight) mean the same thing.- The loss is calculated in the same way over all the features.
7. Training vs. inference: where quality is decided
- Training: you give the program
xandy. It runs gradient descent, finds the best parameters, and saves them in the model file. - Inference: you give only
x. The model puts it intoy = m·x + band returns the answer. Nothing is learned at this stage.
So if predictions are wrong, the problem is in training (poor parameters, poor data), not in inference. Go back, improve the training, and save a better model.
8. Classification: adding the sigmoid

Logistic regression: a linear equation plus the sigmoid
For a loan approval, the two classes are stored as numbers, 0 and 1, with the credit score as the input. The line m·x + b does not work well here because the data is not a straight line. And the output (say, 3000 for a credit score of 300 with m = 10, b = 0) does not tell you a class.
For classification you add an activation function after the linear equation. The one used here is the sigmoid:
sigmoid(z) = 1 / (1 + e^(-z)) where z = m·x + b
It squeezes any number into the range 0 to 1. Then you apply a decision boundary of 0.5:
| Sigmoid output | Class |
|---|---|
| below 0.5 | one class (0) |
| 0.5 or above | the other class (1) |
import math
def sigmoid(z):
return 1 / (1 + math.exp(-z))
z = 10 * 300 + 0 # m*x + b = 3000
p = sigmoid(z) # about 1.0
print(1 if p >= 0.5 else 0) # 1
So classification uses the same m·x + b, plus the sigmoid and a decision boundary. Regression uses the linear equation alone.
Summary
Key takeaways
- Classification picks from fixed classes (binary or multi-class). Regression predicts a continuous number.
- Training data has features and a target. Inference has features only.
- The model is an equation,
y = m·x + b. Training finds the bestmandbby guessing, measuring the loss and adjusting. - Gradient descent is the repeated adjusting, and each round is an epoch.
- With many features, each feature has its own weight, and there is one bias.
- Quality is decided in training. Inference just applies the saved parameters.
- Classification adds the sigmoid and a 0.5 decision boundary to turn the number into a class.
Quick revision
| Term | Meaning |
|---|---|
| Class | One of the fixed categories in a classification problem |
| Loss | One number that says how wrong the predictions are |
| Slope / weight (m, w) | How strongly a feature affects the target |
| Bias (b) | The value of y when all inputs are 0 |
| Gradient descent | Adjusting the parameters step by step to reduce the loss |
| Epoch | One round of that adjusting |
| Sigmoid | Turns any number into a value between 0 and 1 |
| Decision boundary | The cut-off (0.5) that decides the class |
Remember: guess, measure the loss, adjust, repeat.
