Skip to content
Permalink
f9ee841a5c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
63 lines (57 sloc) 2.27 KB
import numpy as np
import experiments_logging as log
import pandas as pd
import interaction_distance as id
import data_generator as dg
def evidence_ID():
# no interaction
b = np.matrix(np.random.uniform(1, 2, (4000, 1)))
back = np.matrix(np.random.uniform(0, 2, (4000, 1)))
res = np.append(b, back, axis=0)
b1 = np.matrix(np.random.uniform(0, 2, (8000, 1)))
# either horizontal or vertical tube
# all = np.append(b1, res, axis=1)
all = np.append(res, b1, axis=1)
df = pd.DataFrame(all)
df = df.sort_values(by=0).reset_index(drop=True)
print(id.compute_ID(df.loc[:100, 1].to_frame(), df.loc[7900:8000, 1].to_frame(), [0, 2]))
# log.plot_data_2d(df)
# log.plot_data_2d(pd.concat([df.loc[:100], df.loc[7900:8000]], axis=0))
# cube interaction
b = np.matrix(np.random.uniform(1, 2, (4000, 1)))
back = np.matrix(np.random.uniform(0, 2, (4000, 1)))
res = np.append(b, back, axis=0)
b1 = np.matrix(np.random.uniform(1, 2, (4000, 1)))
back1 = np.matrix(np.random.uniform(0, 2, (4000, 1)))
res1 = np.append(b1, back1, axis=0)
all = np.append(res, res1, axis=1)
df = pd.DataFrame(all)
df = df.sort_values(by=0).reset_index(drop=True)
print(id.compute_ID(df.loc[:100, 1].to_frame(), df.loc[7900:8000, 1].to_frame(), [0, 2]))
# log.plot_data_2d(df)
# log.plot_data_2d(pd.concat([df.loc[:100], df.loc[7900:8000]], axis=0))
cg = dg.produce_cube_generator(7, 0, 2, "i", ".csv")
data, filname = cg.build()
print(cg.subspaces)
print(cg.perf_disc)
data = pd.DataFrame(data)
dim_count = data.shape[1]
for curr in data[:-1]:
dims = data.columns.tolist()
dims.remove(curr)
dims.remove(dim_count - 1)
curr_data = data.sort_values(by=curr).reset_index(drop=True).loc[:, dims]
rows = curr_data.shape[0]
print('curr dimension', curr)
for dim in dims:
counter = 0
ids = []
while(True):
if counter + 280 > rows:
break
ids.append(id.compute_ID(curr_data.loc[counter:counter + 140, dim].to_frame(),
curr_data.loc[counter + 140: counter + 280, dim].to_frame(), [2] * dim_count))
counter += 1
# needs data normalization todo
print('interaction with', dim, np.average(ids))
# break