1

What is correct way to implement MAPE under h2o framework?

I am interested to convert below function to h2o concept

def mape(a, b): 
    mask = a <> 0
    return (np.fabs(a - b)/a)[mask].mean()
SpanishBoy
  • 2,105
  • 6
  • 28
  • 51

1 Answers1

2
import h2o
h2o.init()
df = h2o.create_frame(rows=100, cols=2, missing_fraction=0, integer_fraction=1, integer_range=5)
print(df)

def mape(a, b):
    mask = a != 0
    return (abs(a-b)/a)[mask].mean()

mape(df[0],df[1])
Arno Candel
  • 491
  • 2
  • 2