def frame_reducers(ip, port):
    # Connect to h2o
    h2o.init(ip, port)

    data = [[random.uniform(-10000, 10000) for r in range(10)]
            for c in range(10)]
    h2o_data = h2o.H2OFrame(python_obj=data)
    np_data = np.array(data)

    row, col = h2o_data.dim()

    c = random.randint(0, col - 1)
    h2o_val = h2o.min(h2o_data[c])
    num_val = np.min(np_data[:, c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal min values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.max(h2o_data[c])
    num_val = np.max(np_data[:, c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal max values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sum(h2o_data[c])
    num_val = np.sum(np_data[:, c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sum values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sd(h2o_data[c])
    num_val = np.std(np_data[:, c], axis=0, ddof=1)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sd values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.var(h2o_data[c])
    num_val = np.var(np_data[:, c], ddof=1)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal var values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.mean(h2o_data[c])
    num_val = np.mean(np_data[:, c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal mean values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.median(h2o_data[c])
    num_val = np.median(np_data[:, c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal median values between h2o and " \
        "numpy".format(h2o_val,num_val)
def frame_reducers(ip,port):
    # Connect to h2o
    h2o.init(ip,port)

    data = [[random.uniform(-10000,10000) for r in range(10)] for c in range(10)]
    h2o_data = h2o.H2OFrame(python_obj=data)
    np_data = np.array(data)

    row, col = h2o_data.dim()

    c = random.randint(0,col-1)
    h2o_val = h2o.min(h2o_data[c])
    num_val = np.min(np_data[:,c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal min values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.max(h2o_data[c])
    num_val = np.max(np_data[:,c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal max values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sum(h2o_data[c])
    num_val = np.sum(np_data[:,c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sum values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sd(h2o_data[c])
    num_val = np.std(np_data[:,c], axis=0, ddof=1)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sd values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.var(h2o_data[c])
    num_val = np.var(np_data[:,c], ddof=1)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal var values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.mean(h2o_data[c])
    num_val = np.mean(np_data[:,c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal mean values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.median(h2o_data[c])
    num_val = np.median(np_data[:,c])
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal median values between h2o and " \
        "numpy".format(h2o_val,num_val)
def expr_reducers(ip, port):
    # Connect to h2o
    h2o.init(ip, port)

    data = [[random.uniform(-10000, 10000) for r in range(10)]
            for c in range(10)]
    h2o_data = h2o.H2OFrame(python_obj=data)
    np_data = np.array(data)
    row, col = h2o_data.dim()
    h2o_data = h2o_data + 2
    np_data = np_data + 2

    def check_values(h2o_data, numpy_data):
        success = True
        for i in range(10):
            r = random.randint(0, row - 1)
            c = random.randint(0, col - 1)
            h2o_val = h2o_data[r, c]
            num_val = numpy_data[r, c]
            if not abs(h2o_val - num_val) < 1e-06:
                success = False
                print "check unsuccessful! h2o computed {0} and numpy computed {1}".format(
                    h2o_val, num_val)
        return success

    h2o_val = h2o.min(h2o_data)
    num_val = np.min(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal min values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.max(h2o_data)
    num_val = np.max(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal max values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sum(h2o_data)
    num_val = np.sum(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sum values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o.np_comparison_check(h2o.var(h2o_data), np.cov(np_data, rowvar=0, ddof=1), 10), \
        "expected equal var values between h2o and numpy"
def expr_reducers(ip,port):
    # Connect to h2o
    h2o.init(ip,port)

    data = [[random.uniform(-10000,10000) for r in range(10)] for c in range(10)]
    h2o_data = h2o.H2OFrame(python_obj=data)
    np_data = np.array(data)
    row, col = h2o_data.dim()
    h2o_data = h2o_data + 2
    np_data = np_data + 2

    def check_values(h2o_data, numpy_data):
        success = True
        for i in range(10):
            r = random.randint(0,row-1)
            c = random.randint(0,col-1)
            h2o_val = h2o_data[r,c]
            num_val = numpy_data[r,c]
            if not abs(h2o_val - num_val) < 1e-06:
                success = False
                print "check unsuccessful! h2o computed {0} and numpy computed {1}".format(h2o_val,num_val)
        return success

    h2o_val = h2o.min(h2o_data)
    num_val = np.min(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal min values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.max(h2o_data)
    num_val = np.max(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal max values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sum(h2o_data)
    num_val = np.sum(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sum values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o.np_comparison_check(h2o.var(h2o_data), np.cov(np_data, rowvar=0, ddof=1), 10), \
        "expected equal var values between h2o and numpy"
예제 #5
0
def frame_reducers(ip,port):
    # Connect to h2o
    h2o.init(ip,port)

    data = [[random.uniform(-10000,10000) for r in range(10)] for c in range(10)]
    h2o_data = h2o.H2OFrame(python_obj=data)
    np_data = np.array(data)

    h2o_val = h2o.min(h2o_data)
    num_val = np.min(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal min values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.max(h2o_data)
    num_val = np.max(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal max values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sum(h2o_data)
    num_val = np.sum(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sum values between h2o and " \
        "numpy".format(h2o_val,num_val)
예제 #6
0
def frame_reducers(ip, port):
    # Connect to h2o
    h2o.init(ip, port)

    data = [[random.uniform(-10000, 10000) for r in range(10)]
            for c in range(10)]
    h2o_data = h2o.H2OFrame(python_obj=data)
    np_data = np.array(data)

    h2o_val = h2o.min(h2o_data)
    num_val = np.min(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal min values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.max(h2o_data)
    num_val = np.max(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal max values between h2o and " \
        "numpy".format(h2o_val,num_val)
    h2o_val = h2o.sum(h2o_data)
    num_val = np.sum(np_data)
    assert abs(h2o_val - num_val) < 1e-06, \
        "check unsuccessful! h2o computed {0} and numpy computed {1}. expected equal sum values between h2o and " \
        "numpy".format(h2o_val,num_val)