-
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 #15 from UBC-MDS/mape
added MAPE function and renamed MSE function
- Loading branch information
Showing
2 changed files
with
35 additions
and
6 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,35 @@ | ||
# Mean Absolute Percentage Error (MAPE) calculation | ||
def mean_absolute_percentage_error(y_true, y_pred): | ||
""" | ||
Calculate the Mean Absolute Percentage Error (MAPE) metric for regression. | ||
This function computes the average percentage difference between the predicted values (`y_pred`) | ||
and the actual values (`y_true`). It measures the relative magnitude of errors in prediction, | ||
expressed as a percentage. MAPE is widely used to evaluate regression models, especially when | ||
relative error matters more than absolute error. | ||
Parameters: | ||
---------- | ||
y_true : array-like | ||
True values of the target variable. | ||
y_pred : array-like | ||
Predicted values from the model. | ||
Returns: | ||
------- | ||
float | ||
The Mean Absolute Percentage Error (as a percentage). | ||
Notes: | ||
------ | ||
MAPE is defined as: | ||
MAPE = (1 / n) * sum(|(y_true - y_pred) / y_true|) * 100 | ||
where n is the number of observations. | ||
Examples: | ||
--------- | ||
>>> y_true = [100, 200, 300] | ||
>>> y_pred = [110, 190, 290] | ||
>>> mean_absolute_percentage_error(y_true, y_pred) | ||
3.3333 | ||
""" |
6 changes: 0 additions & 6 deletions
6
src/matrics_calculator/matrics_calculator.py → src/matrics_calculator/MSE.py
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 |
---|---|---|
@@ -1,10 +1,4 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# Mean Squared Error (MSE) calculation | ||
def mean_squared_error(y_true, y_pred): | ||
""" | ||
|