Skip to content

Commit

Permalink
Add examples to demonstrate usage of mean_absolute_error function
Browse files Browse the repository at this point in the history
  • Loading branch information
“Celine committed Jan 10, 2025
1 parent 17a42aa commit c47d5be
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/matrics_calculator/MAE.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mean Absolute Error (MAE) calculation
def mean_absolute_error(y_true, y_pred):
"""
"""
Calculate the Mean Absolute Error (MAE) metric for regression.
This function computes the average absolute difference between the predicted values (`y_pred`)
Expand All @@ -17,4 +17,18 @@ def mean_absolute_error(y_true, y_pred):
Returns:
-------
float
The Mean Absolute Error.
The Mean Absolute Error.
Notes:
------
MAE is defined as:
MAE = (1 / n) * sum(|y_true - y_pred|)
where n is the number of observations.
Examples:
---------
>>> y_true = [100, 200, 300]
>>> y_pred = [110, 190, 290]
>>> mean_absolute_error(y_true, y_pred)
10.0
"""

0 comments on commit c47d5be

Please sign in to comment.