Lesson 1 of 15
Linear Regression
Linear Regression
Linear regression is the simplest supervised learning model. It learns a linear mapping from an input to an output :
where is the weight (slope) and is the bias (intercept).
Mean Squared Error
To measure how well the model fits the data, we use the Mean Squared Error (MSE):
A perfect model has MSE = 0. Higher MSE means worse predictions.
R-Squared
The coefficient of determination measures how much variance in is explained by the model:
where:
- — residual sum of squares
- — total sum of squares
means a perfect fit; means the model is no better than predicting the mean.
Your Task
Implement:
predict(x, w, b)— returnsmse_loss(y_pred, y_true)— mean of squared differencesr_squared(y_pred, y_true)— coefficient of determination
Python runtime loading...
Loading...
Click "Run" to execute your code.