๐ Understanding the Cost Function (Mean Squared Error)
In machine learning, a cost function tells us how well a model is performing. One of the most common cost functions used in regression problems is Mean Squared Error (MSE).
๐ Step-by-Step Explanation
A model makes predictions (for example, predicting a student's test score), and we compare these predictions with the actual results.
For each prediction, calculate the difference between the predicted value and the actual value. This difference is known as the error.
Squaring the error ensures all values are positive and penalizes larger mistakes more heavily.
The squared errors are averaged to produce a single value — the cost.
๐ Cost Function Formula
n: number of data points
yi: actual value
ลทi: predicted value
๐ป CLI Output Example
- Lower cost = better model performance
- Squaring errors emphasizes large mistakes
- MSE is smooth and easy to optimize
- Widely used in linear regression problems
No comments:
Post a Comment