Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍
https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.7 KiB
82 lines
2.7 KiB
4 years ago
|
import sys
|
||
|
sys.path.append('../')
|
||
|
|
||
|
import structure_graph.abstract_sample_path as asam
|
||
|
import utility.json_importer as imp
|
||
|
import structure_graph.structure as st
|
||
|
import structure_graph.trajectory as tr
|
||
|
|
||
5 years ago
|
|
||
|
|
||
4 years ago
|
class SamplePath(asam.AbstractSamplePath):
|
||
5 years ago
|
"""
|
||
4 years ago
|
Aggregates all the informations about the trajectories, the real structure of the sampled net and variables
|
||
|
cardinalites.
|
||
|
Has the task of creating the objects that will contain the mentioned data.
|
||
|
:importer: the Importer objects that will import ad process data
|
||
4 years ago
|
|
||
4 years ago
|
:trajectories: the Trajectory object that will contain all the concatenated trajectories
|
||
|
:structure: the Structure Object that will contain all the structurral infos about the net
|
||
|
:total_variables_count: the number of variables in the net
|
||
4 years ago
|
|
||
5 years ago
|
"""
|
||
5 years ago
|
|
||
4 years ago
|
#def __init__(self, files_path: str, samples_label: str, structure_label: str, variables_label: str, time_key: str,
|
||
|
#variables_key: str):
|
||
|
def __init__(self, importer: imp.JsonImporter):
|
||
|
#self.importer =importer
|
||
|
super().__init__(importer)
|
||
|
#self._trajectories = None
|
||
|
#self._structure = None
|
||
4 years ago
|
self.total_variables_count = None
|
||
5 years ago
|
|
||
|
def build_trajectories(self):
|
||
4 years ago
|
"""
|
||
|
Builds the Trajectory object that will contain all the trajectories.
|
||
4 years ago
|
Clears all the unused dataframes in Importer Object
|
||
4 years ago
|
|
||
|
Parameters:
|
||
|
void
|
||
|
Returns:
|
||
|
void
|
||
|
"""
|
||
4 years ago
|
self.importer.import_data()
|
||
4 years ago
|
self._trajectories = \
|
||
|
tr.Trajectory(self.importer.build_list_of_samples_array(self.importer.concatenated_samples),
|
||
|
len(self.importer.sorter) + 1)
|
||
4 years ago
|
#self.trajectories.append(trajectory)
|
||
4 years ago
|
self.importer.clear_concatenated_frame()
|
||
5 years ago
|
|
||
4 years ago
|
def build_structure(self):
|
||
4 years ago
|
"""
|
||
|
Builds the Structure object that aggregates all the infos about the net.
|
||
|
Parameters:
|
||
|
void
|
||
|
Returns:
|
||
|
void
|
||
|
"""
|
||
4 years ago
|
self.total_variables_count = len(self.importer.sorter)
|
||
4 years ago
|
labels = self.importer.variables[self.importer.variables_key].to_list()
|
||
4 years ago
|
#print("SAMPLE PATH LABELS",labels)
|
||
4 years ago
|
indxs = self.importer.variables.index.to_numpy()
|
||
|
vals = self.importer.variables['Value'].to_numpy()
|
||
|
edges = list(self.importer.structure.to_records(index=False))
|
||
4 years ago
|
self._structure = st.Structure(labels, indxs, vals, edges,
|
||
4 years ago
|
self.total_variables_count)
|
||
4 years ago
|
|
||
|
@property
|
||
|
def trajectories(self):
|
||
|
return self._trajectories
|
||
|
|
||
|
@property
|
||
|
def structure(self):
|
||
|
return self._structure
|
||
4 years ago
|
|
||
4 years ago
|
def total_variables_count(self):
|
||
|
return self.total_variables_count
|
||
|
|
||
|
|
||
|
|
||
4 years ago
|
|
||
4 years ago
|
|