-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from UBC-MDS/mse
edited function MSE doc
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# Mean Squared Error (MSE) calculation | ||
def mean_squared_error(y_true, y_pred): | ||
""" | ||
Calculate the Mean Squared Error (MSE) between actual and predicted values. | ||
This function computes the average squared difference between the predicted values (`y_pred`) | ||
and the actual values (`y_true`). It is commonly used as a metric to evaluate regression models. | ||
Parameters | ||
---------- | ||
y_true : list or array-like | ||
The actual observed values. | ||
y_pred : list or array-like | ||
The predicted values from the model. | ||
Returns | ||
------- | ||
float | ||
The Mean Squared Error (MSE) value, which is non-negative. | ||
A smaller value indicates that the predictions are closer to the actual values. | ||
Notes | ||
----- | ||
This function assumes that the input `y_true` and `y_pred` have the same length. | ||
Examples | ||
-------- | ||
>>> y_true = [3, -0.5, 2, 7] | ||
>>> y_pred = [2.5, 0.0, 2, 8] | ||
>>> mean_squared_error(y_true, y_pred) | ||
0.375 | ||
""" | ||
pass | ||
|