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_fwdavgnn_kpoints(): """Test FwdAvgNN with k point provided : all request should get the same prediction.""" result = True for i in range(50): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNForwardModel(n, m, k = k) for i in range(k): x = np.random.rand(n) y = np.random.rand(m) model.add_xy(x, y) x = np.random.rand(n) ypg = model.predict_y(x) for i in range(10): x = np.random.rand(n) ye = ypg yp = model.predict_y(x) check = np.allclose(ye, yp, rtol = 1e-10, atol = 1e-10) if not check: print('Error:', ye, yp) result = result and check return result
def test_fwdavgnn_samepoint(): """Test FwdAvgNN with one point provided multiple times.""" result = True for i in range(50): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNForwardModel(n, m, k = k) x = np.random.rand(n) y = np.random.rand(m) for i in range(random.randint(1, 20)): model.add_xy(x, y) for i in range(10): x = np.random.rand(n) ye = y yp = model.predict_y(x) check = np.allclose(ye, yp, rtol = 1e-10, atol = 1e-10) if not check: print('Error:', x, ye, yp) 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_fwdavgnn_samepoint(): """Test FwdAvgNN with one point provided multiple times.""" result = True for i in range(50): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNForwardModel(n, m, k=k) x = np.random.rand(n) y = np.random.rand(m) for i in range(random.randint(1, 20)): model.add_xy(x, y) for i in range(10): x = np.random.rand(n) ye = y yp = model.predict_y(x) check = np.allclose(ye, yp, rtol=1e-10, atol=1e-10) if not check: print('Error:', x, ye, yp) result = result and check return result
def test_fwdavgnn_kpoints(): """Test FwdAvgNN with k point provided : all request should get the same prediction.""" result = True for i in range(50): n = random.randint(1, 20) m = random.randint(1, 20) k = random.randint(1, 20) model = AverageNNForwardModel(n, m, k=k) for i in range(k): x = np.random.rand(n) y = np.random.rand(m) model.add_xy(x, y) x = np.random.rand(n) ypg = model.predict_y(x) for i in range(10): x = np.random.rand(n) ye = ypg yp = model.predict_y(x) check = np.allclose(ye, yp, rtol=1e-10, atol=1e-10) if not check: print('Error:', ye, yp) result = result and check return result