Making a Prediction
After the neural network processes the input through its layers, the output layer produces a final value. We use that value to make a prediction.
In simple words
The neural network calculates a number. Making a prediction means understanding what that number means for the problem we are solving.
From Input to Prediction
We have already followed the input through the network. The complete flow looks like this:
Input
↓
Hidden Layers
↓
Output Layer
↓
Output Value
↓
Prediction
The important point is that the output value is not always directly the final class or answer. Its meaning depends on the type of problem.
Example 1 — Binary Classification
Suppose we build a neural network that predicts whether a student will pass or fail.
Input:
Study Hours
Attendance
Output:
Pass or Fail
Suppose the output layer uses Sigmoid and produces:
Output = 0.889
For a binary classification problem, this can represent the model's predicted probability of the positive class, assuming the model was designed that way.
0.889 = 88.9%
If we use 0.5 as the decision threshold:
0.889 >= 0.5
Prediction = Pass
Another Binary Example
Suppose another student produces:
Output = 0.23
Using the same 0.5 threshold:
0.23 < 0.5
Prediction = Fail
So the model's output can be converted into a class using a decision rule.
Output >= 0.5 → Positive Class
Output < 0.5 → Negative Class
The threshold of 0.5 is common, but it is not a universal rule. The appropriate threshold can depend on the application and the costs of different errors.
Example 2 — Multi-Class Classification
Now suppose a neural network needs to identify an animal in an image.
There are three possible classes:
Cat
Dog
Bird
The output layer might produce:
Cat = 0.80
Dog = 0.15
Bird = 0.05
The largest output is:
Cat = 0.80
Therefore, the predicted class is:
Prediction = Cat
Why Do We Get Multiple Values?
For a multi-class problem, the output layer commonly uses Softmax when the classes are mutually exclusive.
Softmax converts the output scores into values that can be interpreted as probabilities across the classes.
Cat = 0.80
Dog = 0.15
Bird = 0.05
Total = 1.00
The class with the highest probability is commonly selected as the predicted class.
Example 3 — Regression
Not every neural network predicts a class. Some neural networks predict a numerical value.
For example, suppose we want to predict a house price.
Input:
House Size
Bedrooms
Location
Output:
House Price
Suppose the network produces:
Output = 250000
The prediction is:
Predicted Price = $250,000
There is no "choose the largest class" step here. The output itself is the predicted numerical value.
The Output Depends on the Problem
So you cannot look at a neural network output and automatically assume it always means the same thing.
Complete Example — Student Prediction
Let's follow one student through the complete network.
The input is:
Study Hours = 5
Attendance = 90
After the hidden layers, suppose we get:
Hidden Output:
[3.0, 2.0, 0.9]
The output layer calculates:
z = (3.0 × 0.4)
+ (2.0 × 0.3)
+ (0.9 × 0.2)
+ 0.1
z = 2.08
Apply Sigmoid:
Sigmoid(2.08) ≈ 0.889
Now interpret the result:
0.889 = 88.9%
88.9% >= 50%
Prediction = Pass
Prediction vs Probability
These two ideas are related but they are not exactly the same.
Model Output:
0.889
Probability:
88.9%
Decision:
Pass
The neural network produces the output value. A separate decision rule can then turn that value into a class.
This distinction becomes important when you later learn about classification thresholds and model evaluation.
Making a Prediction With Python
We can convert the model output into a simple binary prediction:
prediction_probability = 0.889
threshold = 0.5
if prediction_probability >= threshold:
prediction = "Pass"
else:
prediction = "Fail"
print("Probability:", prediction_probability)
print("Prediction:", prediction)
Output:
Probability: 0.889
Prediction: Pass
Multi-Class Prediction With Python
Suppose the model gives us three class probabilities:
probabilities = {
"Cat": 0.80,
"Dog": 0.15,
"Bird": 0.05
}
We can select the class with the highest probability:
prediction = max(
probabilities,
key=probabilities.get
)
print(prediction)
Output:
Cat
Important
A prediction is not a guarantee that the answer is correct.
If a model predicts 0.89, that does not mean there is an absolute 89% certainty that the event will happen. The interpretation depends on how the model was trained and whether its outputs are well calibrated.
What Happens After a Prediction?
During inference, we can simply use the prediction. During training, however, we compare the prediction with the actual answer.
Input
↓
Forward Propagation
↓
Prediction
↓
Compare With Actual Answer
↓
Calculate Loss
↓
Backpropagation
↓
Update Weights
The loss and backpropagation steps are part of the training process and will be covered later.
The Big Picture
Input
↓
Hidden Layers
↓
Output Layer
↓
Raw Output
↓
Activation Function
↓
Model Output
↓
Decision Rule
↓
Prediction
The exact final step depends on the machine learning problem.
What You Should Remember
Making a prediction means interpreting the output produced by the neural network.
Binary Classification
0.89 → Positive Class
Multi-Class Classification
[0.80, 0.15, 0.05] → Class with highest probability
Regression
250000 → Predicted numerical value
The output format and decision rule depend on the problem the model is solving.
Check Your Understanding
What does the neural network produce?
An output value or set of output values.
Does an output value always directly equal the
final prediction?
No. It may need to be interpreted using a decision
rule depending on the problem.
What happens with binary classification?
A probability-like output can be compared with a
chosen threshold to make a class decision.
What happens with multi-class classification?
The class with the highest output probability is
commonly selected.
What happens with regression?
The output is interpreted as a predicted numerical
value.