1
0
Fork 0

Added parameter index in JSON_importer

master
Luca Moretti 4 years ago
parent 49172e568b
commit 8e3e2019ea
  1. 9
      main_package/classes/utility/json_importer.py
  2. 7
      main_package/tests/optimizers/test_tabu_search.py

@ -32,7 +32,7 @@ class JsonImporter(ai.AbstractImporter):
""" """
def __init__(self, file_path: str, samples_label: str, structure_label: str, variables_label: str, time_key: str, def __init__(self, file_path: str, samples_label: str, structure_label: str, variables_label: str, time_key: str,
variables_key: str): variables_key: str, network_number:int=0):
self.samples_label = samples_label self.samples_label = samples_label
self.structure_label = structure_label self.structure_label = structure_label
self.variables_label = variables_label self.variables_label = variables_label
@ -43,6 +43,7 @@ class JsonImporter(ai.AbstractImporter):
self._df_variables = pd.DataFrame() self._df_variables = pd.DataFrame()
self._concatenated_samples = None self._concatenated_samples = None
self.sorter = None self.sorter = None
self.network_number= network_number
super(JsonImporter, self).__init__(file_path) super(JsonImporter, self).__init__(file_path)
def import_data(self): def import_data(self):
@ -68,7 +69,7 @@ class JsonImporter(ai.AbstractImporter):
Returns: Returns:
void void
""" """
self.normalize_trajectories(raw_data, 0, self.samples_label) self.normalize_trajectories(raw_data, self.network_number, self.samples_label)
def import_structure(self, raw_data: typing.List): def import_structure(self, raw_data: typing.List):
""" """
@ -79,7 +80,7 @@ class JsonImporter(ai.AbstractImporter):
Returns: Returns:
void void
""" """
self._df_structure = self.one_level_normalizing(raw_data, 0, self.structure_label) self._df_structure = self.one_level_normalizing(raw_data, self.network_number, self.structure_label)
def import_variables(self, raw_data: typing.List, sorter: typing.List): def import_variables(self, raw_data: typing.List, sorter: typing.List):
@ -93,7 +94,7 @@ class JsonImporter(ai.AbstractImporter):
Returns: Returns:
void void
""" """
self._df_variables = self.one_level_normalizing(raw_data, 0, self.variables_label) self._df_variables = self.one_level_normalizing(raw_data, self.network_number, self.variables_label)
#self.sorter = self._df_variables[self.variables_key].to_list() #self.sorter = self._df_variables[self.variables_key].to_list()
#self.sorter.sort() #self.sorter.sort()
#print("Sorter:", self.sorter) #print("Sorter:", self.sorter)

@ -23,7 +23,8 @@ class TestTabuSearch(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
#cls.read_files = glob.glob(os.path.join('../../data', "*.json")) #cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_20.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_01_5.json",
'samples', 'dyn.str', 'variables', 'Time', 'Name', 6 )
cls.s1 = sp.SamplePath(cls.importer) cls.s1 = sp.SamplePath(cls.importer)
cls.s1.build_trajectories() cls.s1.build_trajectories()
cls.s1.build_structure() cls.s1.build_structure()
@ -37,9 +38,9 @@ class TestTabuSearch(unittest.TestCase):
se1 = se.StructureScoreBasedEstimator(self.s1) se1 = se.StructureScoreBasedEstimator(self.s1)
edges = se1.estimate_structure( edges = se1.estimate_structure(
max_parents = None, max_parents = None,
iterations_number = 30, iterations_number = 100,
patience = None, patience = None,
tabu_length = 17, tabu_length = 20,
tabu_rules_duration = 20, tabu_rules_duration = 20,
optimizer = 'tabu' optimizer = 'tabu'
) )