def test_get_observation_no_labels(self): ''' get observations from a dataset without labels ''' inputs = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) dataSet = NumericalDataSet(inputs) nrObs = 5 for i in range(nrObs): inputs, target = dataSet.get_observation(i) assert target == None assert_equal(inputs, i * np.ones((1, 3)), 'wrong input at observation %d' % i)
def test_get_observation(self): ''' Test getting a single observation as (1,x) numpy array from input dataset ''' inputs = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) labels = np.array([[0], [1], [2], [3], [4]]) dataSet = NumericalDataSet(inputs, labels) nrObs = 5 for i in range(nrObs): inputs, labels = dataSet.get_observation(i) assert_equal(inputs, i * np.ones((1, 3)), 'wrong input at observation %d' % i) assert_equal(labels, i * np.ones((1, 1)), 'wrong label at observation %d' % i)