Mean absolute scaled error in python

It there a better way to implement the technical indicator MASE ?

In statistics, the mean absolute scaled error (MASE) is a measure of the accuracy of forecasts . It was proposed in 2005 by statistician Rob J. Hyndman and Professor of Decision Sciences Anne B. Koehler, who described it as a “generally applicable measurement of forecast accuracy without the problems seen in the other measurements.”[1] The mean absolute scaled error has favorable properties when compared to other methods for calculating forecast errors, such as root-mean-square-deviation, and is therefore recommended for determining comparative accuracy of forecasts.

def count_MASE(training, testing, prediction):      n = training.shape[0]     d = np.abs(  np.diff( training ).sum()/(n-1)     errors = np.abs(testing- prediction )     return errors.mean()/d