Added ability to pass the filepath as argument

master
Meliurwen 2 years ago
parent 78f2477950
commit e62be8f201
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 3
      .gitignore
  2. 11
      benchmark.py

3
.gitignore vendored

@ -2,7 +2,6 @@
venv/ venv/
.venv/ .venv/
data/ *.json
res/
*.dat *.dat

@ -3,19 +3,20 @@
import glob import glob
import os import os
import time import time
import argparse
from pathlib import Path from pathlib import Path
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
def structure_constraint_based_estimation_example(): def structure_constraint_based_estimation_example(network_file_path):
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>
read_files = glob.glob(os.path.join("./data/", "*.json")) read_files = glob.glob(os.path.join("./data/", "*.json"))
# <initialize a JsonImporter object for the first file> # <initialize a JsonImporter object for the first file>
importer = JsonImporter( importer = JsonImporter(
file_path=read_files[0], file_path=network_file_path,
samples_label='samples', samples_label='samples',
structure_label='dyn.str', structure_label='dyn.str',
variables_label='variables', variables_label='variables',
@ -56,4 +57,8 @@ def structure_constraint_based_estimation_example():
# (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() parser = argparse.ArgumentParser()
parser.add_argument('filename', help="path of the network in json format")
args = parser.parse_args()
structure_constraint_based_estimation_example(args.filename)

Loading…
Cancel
Save