Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
750 B
13
Indexable
Never
def sMAPE(target, predictions):
    predictions = pd.DataFrame(predictions, columns=['rougher.output.recovery', 'final.output.recovery'])
    error1 = 0
    error2 = 0
    n = target.shape[0]
    for i in range(n):
        error1 += ((abs(target['rougher.output.recovery'][i] - predictions['rougher.output.recovery'][i])) / ((abs(target['rougher.output.recovery'][i]) + abs(predictions['rougher.output.recovery'][i])) / 2)) * 100
        error2 += ((abs(target['final.output.recovery'][i] - predictions['final.output.recovery'][i])) / ((abs(target['final.output.recovery'][i]) + abs(predictions['final.output.recovery'][i])) / 2)) * 100
    smape1 = error1/n
    smape2 = error2/n
    smape = 0.25 * smape1 + 0.75 * smape2
    return smape