|
|
@ -4,13 +4,11 @@ import glob |
|
|
|
import os |
|
|
|
import os |
|
|
|
import time |
|
|
|
import time |
|
|
|
from pathlib import Path |
|
|
|
from pathlib import Path |
|
|
|
from memory_profiler import profile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from pyctbn.legacy import JsonImporter |
|
|
|
from pyctbn.legacy import JsonImporter |
|
|
|
from pyctbn.legacy import SamplePath |
|
|
|
from pyctbn.legacy import SamplePath |
|
|
|
from pyctbn.legacy import StructureConstraintBasedEstimator |
|
|
|
from pyctbn.legacy import StructureConstraintBasedEstimator |
|
|
|
|
|
|
|
|
|
|
|
@profile |
|
|
|
|
|
|
|
def structure_constraint_based_estimation_example(): |
|
|
|
def structure_constraint_based_estimation_example(): |
|
|
|
Path("./data").mkdir(parents=True, exist_ok=True) |
|
|
|
Path("./data").mkdir(parents=True, exist_ok=True) |
|
|
|
# <read the json files in ./data path> |
|
|
|
# <read the json files in ./data path> |
|
|
@ -49,13 +47,13 @@ def structure_constraint_based_estimation_example(): |
|
|
|
end_time = time.time() |
|
|
|
end_time = time.time() |
|
|
|
print("Elaspsed time: %d seconds" % (end_time - start_time)) |
|
|
|
print("Elaspsed time: %d seconds" % (end_time - start_time)) |
|
|
|
# obtain the adjacency matrix of the estimated structure |
|
|
|
# obtain the adjacency matrix of the estimated structure |
|
|
|
print(se1.adjacency_matrix()) |
|
|
|
#print(se1.adjacency_matrix()) |
|
|
|
Path("./res").mkdir(parents=True, exist_ok=True) |
|
|
|
Path("./res").mkdir(parents=True, exist_ok=True) |
|
|
|
# save the estimated structure to a json file |
|
|
|
# save the estimated structure to a json file |
|
|
|
# (remember to specify the path AND the .json extension).... |
|
|
|
# (remember to specify the path AND the .json extension).... |
|
|
|
se1.save_results("./res/results0.json") |
|
|
|
se1.save_results("./res/results0.json") |
|
|
|
# ...or save it also in a graphical model fashion |
|
|
|
# ...or save it also in a graphical model fashion |
|
|
|
# (remember to specify the path AND the .png extension) |
|
|
|
# (remember to specify the path AND the .png extension) |
|
|
|
se1.save_plot_estimated_structure_graph("./res/result0.png") |
|
|
|
#se1.save_plot_estimated_structure_graph("./res/result0.png") |
|
|
|
|
|
|
|
|
|
|
|
structure_constraint_based_estimation_example() |
|
|
|
structure_constraint_based_estimation_example() |
|
|
|