Math Project
In this project, we will combine the mathematics we learned throughout this course to build a simple AI-style prediction system. The goal is not to build a production AI model, but to understand how mathematics connects together inside an AI system.
Use mathematical concepts to predict a student's exam score.
We will start with simple input data, perform mathematical calculations, calculate an error, and use that error to improve the prediction.
What Are We Building?
Imagine we want an AI system that predicts a student's exam score.
We can give the system information such as:
Study Hours = 5 Attendance = 90% Previous Score = 70
The AI uses these values to predict the student's next exam score.
Input Data
↓
Mathematical Calculations
↓
Prediction
↓
Compare With Actual Score
↓
Calculate Error
↓
Improve Model
Step 1 — Numbers and Variables
We first represent the student's information using numbers and variables.
study_hours = 5 attendance = 90 previous_score = 70
This connects directly to what we learned in Numbers & Variables.
The variables give meaningful names to the numerical information.
Step 2 — Represent the Data as a Vector
Instead of keeping the values separately, we can represent the student's information as a vector.
X = [5, 90, 70]
Each position represents one feature.
[Study Hours, Attendance, Previous Score] [5, 90, 70]
This is useful because AI models usually work with collections of numerical values rather than individual values.
Step 3 — Add Weights
Not every feature should necessarily have the same influence on the prediction.
We can give each feature a weight.
Study Hours → 0.5 Attendance → 0.2 Previous Score → 0.3
These numbers represent how strongly each input contributes to the prediction in this simplified example.
Step 4 — Use the Dot Product
Now we can combine the inputs and weights using the dot product.
X = [5, 90, 70] W = [0.5, 0.2, 0.3]
Multiply corresponding values and add them together.
(5 × 0.5) + (90 × 0.2) + (70 × 0.3) = 2.5 + 18 + 21 = 41.5
The result is a simple weighted score.
This connects directly to the Dot Product lesson.
Step 5 — Use a Function
A function takes an input and produces an output. We can represent our prediction mathematically as:
prediction = f(X)
In our simplified model:
prediction = X · W + b
Here:
X = input values W = weights b = bias prediction = model output
This is one of the most important patterns in machine learning.
Step 6 — Calculate the Error
Suppose our model predicts:
Predicted Score = 65 Actual Score = 75
The prediction is not correct. We need a way to measure how wrong it is.
Error = Actual - Prediction Error = 75 - 65 Error = 10
This simple error gives us an idea of how far our prediction is from the actual value.
Step 7 — Use a Loss Function
Machine learning usually works with a loss function rather than just looking at the raw error.
For this simple example, we can use squared error.
Loss = (Actual - Prediction)² Loss = (75 - 65)² Loss = 10² Loss = 100
The larger the loss, the worse the prediction.
Our goal during training is to reduce this loss.
Step 8 — Calculate a Gradient
Now we want to know how changing a parameter affects the loss.
This is where gradients become important.
Gradient "What happens to the loss if I change this weight?"
A positive gradient generally tells the optimizer that increasing a parameter would increase the loss.
A negative gradient indicates the opposite direction.
Step 9 — Update the Weight
Once we have a gradient, we can use gradient descent to update the weight.
Old Weight = 0.5 Gradient = 0.2 Learning Rate = 0.1 New Weight = Old Weight - Learning Rate × Gradient = 0.5 - (0.1 × 0.2) = 0.48
The weight has changed slightly. The goal is to move the model toward a lower loss.
Step 10 — Repeat the Process
One update is not enough to train a useful model. The process needs to be repeated.
Input ↓ Prediction ↓ Loss ↓ Gradients ↓ Update Weights ↓ Prediction Again ↓ Loss Again ↓ Update Again ↓ Repeat
Over many iterations, the model can learn parameters that produce better predictions.
Where Does Backpropagation Fit?
In a larger neural network, there can be many layers and many weights.
Backpropagation efficiently calculates the gradients for those weights.
Prediction
↓
Loss
↓
Backpropagation
↓
Gradients
↓
Optimizer
↓
Updated Weights
This connects the project to the final lesson of Math Behind Neural Networks.
Where Does Probability Fit?
Not every AI problem predicts a number such as an exam score. Many AI systems predict probabilities.
Input ↓ AI Model ↓ Probability Cat = 0.85 Dog = 0.10 Other = 0.05
This means the model estimates an 85% probability that the image is a cat.
This connects our project to the probability concepts we learned earlier.
Where Does Statistics Fit?
AI also works with large amounts of data. Statistics helps us understand that data.
Scores: 60 70 70 80 90 Mean = 74 Median = 70
Statistics can help us understand the data before training a model and evaluate the model after training.
Connecting All the Mathematics
This is the most important part of the project. The mathematical concepts we learned are not isolated topics. They work together.
Numbers ↓ Variables ↓ Vectors ↓ Matrices ↓ Functions ↓ Dot Products ↓ Prediction ↓ Probability / Statistics ↓ Loss ↓ Gradients ↓ Backpropagation ↓ Gradient Descent ↓ Better Model
A Simple Python Version
We can represent the basic idea using a small Python program.
study_hours = 5 weight = 10 bias = 20 prediction = study_hours * weight + bias print(prediction)
The model calculates:
prediction = 5 × 10 + 20 = 50 + 20 = 70
This is not a complete machine learning model. It is a deliberately simple example showing the mathematical structure behind prediction.
The Complete Project Flow
Here is the complete idea in one picture.
Student Data
Study Hours
Attendance
Previous Score
↓
Convert to Numbers
↓
Vector
↓
Weights
↓
Mathematical Calculation
↓
Prediction
↓
Compare With Actual Result
↓
Loss
↓
Gradient
↓
Update Weights
↓
Repeat
↓
Better Predictions
What You Should Understand From This Project
You do not need to memorize every formula from this project. The important thing is to understand the relationship between the concepts.
Data ↓ Numbers ↓ Mathematics ↓ Prediction ↓ Error ↓ Gradients ↓ Parameter Updates ↓ Learning
That is the basic mathematical idea behind how many machine learning systems learn from data.
The Most Important Idea
AI is not magically "thinking" when it learns a numerical prediction.
At the mathematical level, a model repeatedly performs calculations, measures its error, calculates how the parameters contributed to that error, and adjusts those parameters.
Calculate ↓ Measure Error ↓ Calculate Gradients ↓ Adjust Parameters ↓ Calculate Again ↓ Repeat
AI mathematics is a connected system, not a collection of unrelated formulas.
Numbers represent information. Vectors and matrices organize that information. Functions transform it. Probability and statistics help us understand uncertainty and data. Loss measures prediction error. Gradients tell us how parameters affect that error. Backpropagation calculates those gradients, and gradient descent uses them to improve the model.