example_code.py 787 Bytes
"""
instruction:
put all code files, data files and dot file in one directory,
and set it as current working directory in the terminal

you need change two places in the code, 
make sure the data and the dot file match with each other
then run the code file in this way:

In terminal, enter: python example_code.py
then you will get the result (BDe score)
"""






import pandas as pd

data = pd.read_csv("XXX") #change XXX to your data file name (csv format)

n, m = data.shape



import myGraph
import score_with_tree


graph = myGraph.Graph()

graph.dot_to_graph('XXX') #change XXX to your dot file name (txt format)

if len(graph.vertices) != m:
	print 'the data doesn\'t match the graph'

myscore = score_with_tree.score(graph, data)
print 'BDe score: %f'  %myscore.BDe()