mean absolute error percentage python 1

mean absolute error percentage python

import numpy as np

def mape(actual, pred): 
    actual, pred = np.array(actual), np.array(pred)
    return np.mean(np.abs((actual - pred) / actual)) * 100

Here is what the above code is Doing:
1. We are using the numpy library to convert the actual and predicted values into arrays.
2. We are then calculating the mean absolute percentage error using the formula given above.
3. Finally, we are multiplying the result by 100 to get the percentage value.

Similar Posts