Esempio n. 1
0
def test_custom_fn_impute(pos1, pos2, expected, mw_data):
    mw_data[pos1, pos2] = np.nan
    imputed = impy.moving_window(mw_data, func=lambda l: max(l) * 2)
    return_na_check(imputed)
    assert imputed[pos1, pos2] == expected
Esempio n. 2
0
def test_custom_nindex_impute_1(pos1, pos2, expected, mw_data):
    mw_data[pos1, pos2] = np.nan
    imputed = impy.moving_window(mw_data, nindex=-1)
    return_na_check(imputed)
    assert imputed[pos1, pos2] == expected
Esempio n. 3
0
def test_custom_nindex_impute_rightmost_index_valid(data):
    data[2][-1] = np.nan
    imputed = impy.moving_window(data, nindex=-1)
    assert not np.isnan(imputed).any()
    assert imputed[2][-1] == 11.5
Esempio n. 4
0
def test_defaults_impute(pos1, pos2, expected, mw_data):
    mw_data[pos1, pos2] = np.nan
    imputed = impy.moving_window(mw_data)
    return_na_check(imputed)
    assert imputed[pos1, pos2] == expected
Esempio n. 5
0
def test_custom_fn_impute_rightmost_index(data):
    data[2][-1] = np.nan
    imputed = impy.moving_window(data, func=lambda l: max(l) * 2)
    assert not np.isnan(imputed).any()
    assert imputed[2][-1] == 26
Esempio n. 6
0
def test_custom_nindex_impute_leftmost_falls_off(data):
    data[2][-1] = np.nan
    imputed = impy.moving_window(data, nindex=0)
    assert not np.isnan(imputed).any()
    assert imputed[2][-1] == 12.5
Esempio n. 7
0
def test_defaults_impute_middle_index(data):
    data[2][2] = np.nan
    imputed = impy.moving_window(data)
    assert not np.isnan(imputed).any()
    assert imputed[2][2] == 12
Esempio n. 8
0
def test_defaults_impute_rightmost_index(data):
    data[2][-1] = np.nan
    imputed = impy.moving_window(data)
    assert not np.isnan(imputed).any()
    assert imputed[2][-1] == 12.5
Esempio n. 9
0
 def test_impute_rightmost_index(self):
     self.data[2][-1] = np.nan
     imputed = impy.moving_window(self.data, nindex=0)
     self.assertFalse(np.isnan(imputed).any())
     self.assertEqual(imputed[2][-1], 12.5)
Esempio n. 10
0
 def test_impute_leftmost_index(self):
     self.data[2][0] = np.nan
     imputed = impy.moving_window(self.data, nindex=-1)
     self.assertFalse(np.isnan(imputed).any())
     self.assertEqual(imputed[2][0], 11.5)
Esempio n. 11
0
 def test_impute_rightmost_index(self):
     self.data[2][-1] = np.nan
     imputed = impy.moving_window(self.data, func=lambda l: max(l) * 2)
     self.assertFalse(np.isnan(imputed).any())
     self.assertEqual(imputed[2][-1], 26)
Esempio n. 12
0
 def test_impute_middle_index(self):
     self.data[2][2] = np.nan
     imputed = impy.moving_window(self.data)
     self.assertFalse(np.isnan(imputed).any())
     self.assertEqual(imputed[2][2], 12)
Esempio n. 13
0
    df = DataFrame(data)
    cols = list()
    # input sequence (t-n, ... t-1)
    for i in range(n_in, 0, -1):
        cols.append(df.shift(i))
    # forecast sequence (t, t+1, ... t+n)
    for i in range(0, n_out):
        cols.append(df.shift(-i))
    # put it all together
    agg = concat(cols, axis=1)

    return agg.values


series = read_csv(
    '../data/datasets/test_datasets/openstack_controller_server_final_week_nan.csv',
    header=0,
    index_col=0,
    parse_dates=True,
    squeeze=True)

A = series_to_supervised(series.values, n_in=3)
# A = series.values.reshape(-1, 1)
test_2 = impy.moving_window(A, wsize=5)
# print(test_2)

pc = PCA(data=A, ncomp=1, missing='fill-em')
# noinspection PyProtectedMember
B = pc._adjusted_data
print(B)