Spaces:
Sleeping
Sleeping
File size: 876 Bytes
b099c5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import numpy as np
# Adding type hints for better code clarity and numpy style comments for documentation
def mae(y_true: np.ndarray, y_pred: np.ndarray) -> float:
"""Mean Absolute Error
Parameters
----------
y_true : np.ndarray
True values
y_pred : np.ndarray
Predicted values
Returns
-------
float
Mean Absolute Error
"""
y_true = np.array(y_true)
y_pred = np.array(y_pred)
return np.mean(np.abs(y_true - y_pred))
def bias(y_true: np.ndarray, y_pred: np.ndarray) -> float:
"""Bias
Parameters
----------
y_true : np.ndarray
True values
y_pred : np.ndarray
Predicted values
Returns
-------
float
Bias
"""
y_true = np.array(y_true)
y_pred = np.array(y_pred)
return np.mean(y_pred - y_true)
|