def test_fwdwnn_kpoints_group(): """Test FwdWNN with group of k same points provided : all request should return point of the dataset.""" result = True size = 30 for i in range(20): n = random.randint(1, size) m = random.randint(1, size) k = random.randint(1, size) sigma = random.uniform(0.1, 10) model = WeightedNNForwardModel(n, m, sigma=sigma, k=k) ygroup = set() for i in range(random.randint(1, size)): x = np.random.rand(n) y = np.random.rand(m) ygroup.add(tuple(y)) for i in range(k): model.add_xy(x, y) for i in range(10): x = np.random.rand(n) yp = model.predict_y(x) check = min([tools.dist(yp, y) for y in ygroup]) < 1e-10 if not check: print('Error:', n, m, k, min([tools.dist(yp, y) for y in ygroup]), yp) result = result and check return result
def test_fwdwnn_kpoints_group(): """Test FwdWNN with group of k same points provided : all request should return point of the dataset.""" result = True size = 30 for i in range(20): n = random.randint(1, size) m = random.randint(1, size) k = random.randint(1, size) sigma = random.uniform(0.1, 10) model = WeightedNNForwardModel(n, m, sigma = sigma, k = k) ygroup = set() for i in range(random.randint(1, size)): x = np.random.rand(n) y = np.random.rand(m) ygroup.add(tuple(y)) for i in range(k): model.add_xy(x, y) for i in range(10): x = np.random.rand(n) yp = model.predict_y(x) check = min([tools.dist(yp, y) for y in ygroup]) < 1e-10 if not check: print('Error:', n, m, k, min([tools.dist(yp, y) for y in ygroup]), yp) result = result and check return result
def test_invwnn_kpoints_group(): """Test InvWNN with group of k same points provided : all request should return point of the dataset.""" result = True for i in range(25): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) sigma = random.uniform(0.1, 10) model = WeightedNNInverseModel(n, m, sigma, k) xgroup = set() for i in range(random.randint(1, 20)): x = np.random.rand(n) y = np.random.rand(m) xgroup.add(tuple(x)) for i in range(k): model.add_xy(x, y) for i in range(10): y = np.random.rand(m) xp = model.infer_x(y)[0] check = min([tools.dist(xp, x) for x in xgroup]) < 1e-10 if not check: print('Error:', n, m, y, xe, xp) result = result and check return result
def test_fwdavgnn_kpoints_group(): """Test FwdAvgNN with group of k same points provided : all request should return point of the dataset.""" result = True for i in range(25): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNForwardModel(n, m, k = k) ygroup = set() for i in range(random.randint(1, 20)): x = np.random.rand(n) y = np.random.rand(m) ygroup.add(tuple(y)) for i in range(k): model.add_xy(x, y) for i in range(10): x = np.random.rand(n) yp = model.predict_y(x) check = min([tools.dist(yp, y) for y in ygroup]) < 1e-10 if not check: print('Error:', x, yp) result = result and check return result
def test_invavgnn_kpoints_group(): """Test InvAvgNN with group of k same points provided : all request should return point of the dataset.""" result = True for i in range(20): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNInverseModel(n, m, k) xgroup = set() for i in range(random.randint(1, 20)): x = np.random.rand(n) y = np.random.rand(m) xgroup.add(tuple(x)) for i in range(k): model.add_xy(x, y) for i in range(10): y = np.random.rand(m) xp = model.infer_x(y)[0] check = min([tools.dist(xp, x) for x in xgroup]) < 1e-10 if not check: print('Error:', n, m, y, xe, xp) result = result and check return result
def test_fwdavgnn_kpoints_group(): """Test FwdAvgNN with group of k same points provided : all request should return point of the dataset.""" result = True for i in range(25): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNForwardModel(n, m, k=k) ygroup = set() for i in range(random.randint(1, 20)): x = np.random.rand(n) y = np.random.rand(m) ygroup.add(tuple(y)) for i in range(k): model.add_xy(x, y) for i in range(10): x = np.random.rand(n) yp = model.predict_y(x) check = min([tools.dist(yp, y) for y in ygroup]) < 1e-10 if not check: print('Error:', x, yp) result = result and check return result