https://github.com/dms-codes/mean-absolute-error
https://github.com/dms-codes/mean-absolute-error
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dms-codes/mean-absolute-error
- Owner: dms-codes
- Created: 2024-12-07T01:36:09.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-12-07T01:40:47.000Z (7 months ago)
- Last Synced: 2025-01-18T21:20:02.177Z (6 months ago)
- Language: Python
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mean Absolute Error (MAE) Calculation
This Python function calculates the Mean Absolute Error (MAE) between two lists of values.
def mean_absolute_error(actual, calculated):
"""
Calculates the Mean Absolute Error (MAE) between two lists.Args:
actual: A list of actual values.
calculated: A list of calculated values.Returns:
The Mean Absolute Error.Raises:
ValueError: If the lengths of the input lists are not equal.
"""
if len(actual) != len(calculated):
raise ValueError("Actual and calculated lists must have the same length.")errors = [abs(a - c) for a, c in zip(actual, calculated)]
return sum(errors) / len(actual)