example_code.py
787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
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()