antoinecarme / pyaf

PyAF is an Open Source Python library for Automatic Time Series Forecasting built on top of popular pydata modules.
BSD 3-Clause "New" or "Revised" License
459 stars 72 forks source link

MAPE, sMAPE computations are slow #42

Closed antoinecarme closed 7 years ago

antoinecarme commented 7 years ago

PyAF protects these indicators against zero values in the signal :

def protect_small_values(self, signal, estimator):
    eps = 1.0e-13;
    keepThis = (np.abs(signal) > eps);
    signal1 =  signal[keepThis];       
    estimator1 = estimator[keepThis];
    # self.dump_perf_data(signal , signal1);        
    return (signal1 , estimator1);

This is not necessary.

An approximation is better :

rel_error = abs(estimator - signal) / (abs(signal) + eps) MAPE = mean(rel_error)