-
Notifications
You must be signed in to change notification settings - Fork 8
/
bnc
26 lines (20 loc) · 1.2 KB
/
bnc
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
#!/usr/bin/env python2.5
from BNfinder.data import dataset
if __name__=="__main__":
import sys
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-c", "--cpd", dest="cpd",help="Input file with the conditional probability distributions gotten from bnfinder")
parser.add_option("-d", "--data", dest="data",help="Input file with values of regulator variables.")
parser.add_option("-m", "--ml", dest="ml",default=False,help="Should we output only the most likely value.")
parser.add_option("-p", "--prob", dest="prob",type=int,help="Output the probability of given class value (for all nodes).")
parser.add_option("-o", "--out", dest="out",default=sys.stdout,help="Output file.")
(options, args) = parser.parse_args()
if options.cpd==None or options.data==None:
print "You must provide a cpd file and input data. Run bnc --help for more options."
else:
cpd=eval(open(options.cpd).read())
d=dataset().fromNewFile(open(options.data),float_transform=None)
if options.out!=sys.stdout:
options.out=open(options.out,"w")
d.classify(cpd,options.out,ML=options.ml,prob=options.prob,transformed=False)