|
|
@ -6,40 +6,36 @@ from PyCTBN.PyCTBN.structure_graph.structure import Structure |
|
|
|
from PyCTBN.PyCTBN.structure_graph.sample_path import SamplePath |
|
|
|
from PyCTBN.PyCTBN.structure_graph.sample_path import SamplePath |
|
|
|
from PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator import StructureConstraintBasedEstimator |
|
|
|
from PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator import StructureConstraintBasedEstimator |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
def main(): |
|
|
|
if __name__ == "__main__": |
|
|
|
# Network Generation |
|
|
|
trajectories = tg.multi_trajectory(t_ends = [100, 100, 100]) |
|
|
|
labels = ["X", "Y", "Z"] |
|
|
|
""" |
|
|
|
card = 3 |
|
|
|
|
|
|
|
vals = [card for l in labels] |
|
|
|
|
|
|
|
cim_min = 1 |
|
|
|
|
|
|
|
cim_max = 3 |
|
|
|
|
|
|
|
ng = NetworkGenerator(labels, vals) |
|
|
|
|
|
|
|
ng.generate_graph(0.3) |
|
|
|
|
|
|
|
ng.generate_cims(cim_min, cim_max) |
|
|
|
|
|
|
|
|
|
|
|
# Network Generation |
|
|
|
# Trajectory Generation |
|
|
|
labels = ["X", "Y", "Z"] |
|
|
|
e1 = JsonExporter(ng.variables, ng.dyn_str, ng.cims) |
|
|
|
card = 3 |
|
|
|
tg = TrajectoryGenerator(variables = ng.variables, dyn_str = ng.dyn_str, dyn_cims = ng.cims) |
|
|
|
vals = [card for l in labels] |
|
|
|
sigma = tg.CTBN_Sample(max_tr = 30000) |
|
|
|
cim_min = 1 |
|
|
|
e1.add_trajectory(sigma) |
|
|
|
cim_max = 3 |
|
|
|
e1.out_file("example.json") |
|
|
|
ng = NetworkGenerator(labels, vals) |
|
|
|
|
|
|
|
ng.generate_graph(0.3) |
|
|
|
|
|
|
|
ng.generate_cims(cim_min, cim_max) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Trajectory Generation |
|
|
|
# Network Estimation (Constraint Based) |
|
|
|
print(ng.dyn_str) |
|
|
|
importer = JsonImporter(file_path = "example.json", samples_label = "samples", |
|
|
|
e1 = JsonExporter(ng.variables, ng.dyn_str, ng.cims) |
|
|
|
structure_label = "dyn.str", variables_label = "variables", |
|
|
|
tg = TrajectoryGenerator(variables = ng.variables, dyn_str = ng.dyn_str, dyn_cims = e1.cims_to_json()) |
|
|
|
cims_label = "dyn.cims", time_key = "Time", |
|
|
|
sigma = tg.CTBN_Sample(max_tr = 30000) |
|
|
|
variables_key = "Name") |
|
|
|
e1.add_trajectory(sigma) |
|
|
|
importer.import_data(0) |
|
|
|
e1.out_file("example.json") |
|
|
|
s1 = SamplePath(importer=importer) |
|
|
|
|
|
|
|
s1.build_trajectories() |
|
|
|
# Network Estimation (Constraint Based) |
|
|
|
s1.build_structure() |
|
|
|
importer = JsonImporter(file_path="example.json", samples_label='samples', |
|
|
|
se1 = StructureConstraintBasedEstimator(sample_path=s1, exp_test_alfa=0.1, chi_test_alfa=0.1, |
|
|
|
structure_label='dyn.str', variables_label='variables', |
|
|
|
|
|
|
|
time_key='Time', variables_key='Name') |
|
|
|
|
|
|
|
importer.import_data(0) |
|
|
|
|
|
|
|
s1 = SamplePath(importer=importer) |
|
|
|
|
|
|
|
s1.build_trajectories() |
|
|
|
|
|
|
|
s1.build_structure() |
|
|
|
|
|
|
|
se1 = StructureConstraintBasedEstimator(sample_path=s1, exp_test_alfa=0.1, chi_test_alfa=0.1, |
|
|
|
|
|
|
|
known_edges=[], thumb_threshold=25) |
|
|
|
known_edges=[], thumb_threshold=25) |
|
|
|
edges = se1.estimate_structure(True) |
|
|
|
edges = se1.estimate_structure(True) |
|
|
|
# se1.save_plot_estimated_structure_graph('./result1.png') |
|
|
|
|
|
|
|
print(se1.adjacency_matrix()) |
|
|
|
if __name__ == "__main__": |
|
|
|
print(edges) |
|
|
|
main() |