mean bias error 1

mean bias error

def MBE(y_true, y_pred):
    '''
    Parameters:
        y_true (array): Array of observed values
        y_pred (array): Array of prediction values

    Returns:
        mbe (float): Biais score
    '''
    y_true = np.array(y_true)
    y_pred = np.array(y_pred)
    y_true = y_true.reshape(len(y_true),1)
    y_pred = y_pred.reshape(len(y_pred),1)   
    diff = (y_true-y_pred)
    mbe = diff.mean()
    print('MBE = ', mbe)

Here is what the above code is Doing:
1. We’re importing the numpy library as np.
2. We’re defining a function called MBE that takes two arguments: y_true and y_pred.
3. We’re converting y_true and y_pred to numpy arrays.
4. We’re reshaping y_true and y_pred to be column vectors.
5. We’re calculating the difference between y_true and y_pred.
6. We’re calculating the mean of the difference.
7. We’re printing the mean of the difference.

Similar Posts