def test_osm_cellids(self):
        init_('../datipisa/segments_osm_cellids_1M_uint64.csv', "../datipisa/osm_cellids_1M_uint64")
        pgm = pgm_index(neuroni, init, slope, intercept, False)
        y = pgm.predict(chiavi).reshape(-1, 1)
        index = [0]
        for i in range(1, len(chiavi)):
            if chiavi[i] == chiavi[i - 1]:
                index.append(index[i - 1])
            else:
                index.append(i)
        err = []

        for i in range(len(chiavi)):
            diff = abs(y[i, 0] - index[i])
            err.append(diff)

        x = all(i <= 64.1 for i in err)
        self.assertEqual(True, x)
 def test_pgm(self):
     model = pgm_index(2, w, slope, intercept, False)
     x = model.predict([10])
     y = np.array([[2]])
     self.assertTrue((x == y).all())
Example #3
0
x_train = np.fromfile("datipisa/wiki_ts_1M_uint64", dtype=np.uint64)

x_train = x_train.reshape(len(x_train), 1)

index = [0]
for i in range(1, len(x_train)):
    if x_train[i] == x_train[i - 1]:
        index.append(index[i-1])
    else:
        index.append(i)

init = indice['key'].to_numpy().reshape(1, len(indice))
slope = indice['slope'].to_numpy().reshape(1, len(indice))
intercept = indice['intercept'].to_numpy().reshape(1, len(indice))
neuroni = len(indice)
pgm = pgm_index(neuroni, init, slope, intercept, True, dati)

# calcolo media con valori presi dai dati
y = pgm.predict(x_train)

err = []
for i in range(len(x_train)):
    diff = abs(y[i, 0] - index[i])
    err.append(diff)
err_max_init = np.amax(err)
err_medio_init = np.average(err)

init_custom = input("init pesi random? Y/N ")
if init_custom == 'Y':
    dati = False