Esempio n. 1
0
def module_help(exit_value=1,message=""):
    """
    defines help viewed if args are not OK on command line, and exit with exit_value
    """
    print(os.path.basename(sys.argv[0]),"src.{"+gum.availableBNExts()+"} data[.csv] variable label")
    print()
    print(message)
    print()
    sys.exit(exit_value)
Esempio n. 2
0
def module_help(exit_value=1):
    """
    defines help viewed if args are not OK on command line, and exit with exit_value
    """
    print os.path.basename(sys.argv[0]), "src.{" + gum.availableBNExts() + "}"
    sys.exit(exit_value)
Esempio n. 3
0
def module_help(exit_value=1):
    """
    defines help viewed if args are not OK on command line, and exit with exit_value
    """
    print os.path.basename(sys.argv[0]),"src.{"+gum.availableBNExts()+"}"
    sys.exit(exit_value)
Esempio n. 4
0
      namesList+="\n#(@TODO) "
    else:
      n+=1
      namesList+="\t"
      
  namesLanguage="#(@TODO) "+"\t".join(languages)
  
  signature('# Yaml config file automatically generated by ')
  print(Conf.template_yaml.format(BNfilename,namesList,namesLanguage,radical))
  
if __name__=='__main__':
  if (len(sys.argv)<2):
    signature()
    about()
  else:
    filename=sys.argv[1]
    if not os.path.exists(filename):
      signature()
      print("File '{}' not found.\n".format(filename))
      about()
    else:
      bname,ext=os.path.splitext(filename)
      if ext=='.yaml':
        signature()
        generation(filename)
      elif ext[1:] in gum.availableBNExts().split('|'):
        documentor(filename)
      else:
        signature()
        print("File '{}' is neither a yaml configuration file nor a recognized Bayesian Network file.\n".format(filename))
        about()
Esempio n. 5
0
  f=open(dotfile,'w')
  f.write(bn.toDot())
  f.close()

  cmd=['dot','-T'+style,dotfile,('-o'+pngfile)]
  return subprocess.call(cmd)


def pngize(aBN,name):
  """
  From a bn 'bn' and a name 'bn', pngize creates 'bn.dot' and 'bn.png', representation of the bn in
	dot format and in png.
  """
  dotize(aBN,name,'png')

def pdfize(aBN,name):
  """
  From a bn 'bn' and a name 'bn', pdfize creates 'bn.dot' and 'bn.pdf', representation of the bn in
	dot format and in pdf.
  """
  dotize(aBN,name,'pdf')

if __name__=="__main__":
    pyAgrum_header("2011-13")

    if len(sys.argv)<2:
        print(os.path.basename(sys.argv[0]),"file.{"+gum.availableBNExts()+"}")
    else:
        base,ext=os.path.splitext(sys.argv[1])
        pngize(sys.argv[1],base)
Esempio n. 6
0
import pyAgrum as gum
from gumLib.pyAgrum_header import pyAgrum_header

pyAgrum_header(2011)

bn = gum.BayesNet('exo1')

# sexe = 0(H)/1(F)
# daltonisme = 0(D) / 1 (nonD)

sexe, daltonisme = [
    bn.add(gum.LabelizedVar(nom, '', 2)) for nom in 'sexe daltonisme'.split()
]
bn.insertArc(sexe, daltonisme)

bn.cpt(sexe)[:] = [0.5, 0.5]

bn.cpt(daltonisme)[0, :] = [0.08, 0.92]
bn.cpt(daltonisme)[1, :] = [0.005, 0.995]

bn.saveBIF("exo1.bif")
for line in open("exo1.bif"):
    print line,

print("for gum.loadBN or gum.saveBN, possible files ext are =" +
      gum.availableBNExts())
gum.saveBN(bn, "exo1.dsl")
for line in open("exo1.dsl"):
    print line,
Esempio n. 7
0
    namesLanguage = "#(@TODO) " + "\t".join(languages)

    signature('# Yaml config file automatically generated by ')
    print(
        Conf.template_yaml.format(BNfilename, namesList, namesLanguage,
                                  radical))


if __name__ == '__main__':
    if (len(sys.argv) < 2):
        signature()
        about()
    else:
        filename = sys.argv[1]
        if not os.path.exists(filename):
            signature()
            print("File '{}' not found.\n".format(filename))
            about()
        else:
            bname, ext = os.path.splitext(filename)
            if ext == '.yaml':
                signature()
                generation(filename)
            elif ext[1:] in gum.availableBNExts().split('|'):
                documentor(filename)
            else:
                signature()
                print(
                    "File '{}' is neither a yaml configuration file nor a recognized Bayesian Network file.\n"
                    .format(filename))
                about()
Esempio n. 8
0
#OR PERFORMANCE OF THIS SOFTWARE!# -*- coding: utf-8 -*-

import sys

import pyAgrum as gum
from gumLib.pyAgrum_header import pyAgrum_header

pyAgrum_header(2011)

bn=gum.BayesNet('exo1')

# sexe = 0(H)/1(F)
# daltonisme = 0(D) / 1 (nonD)

sexe,daltonisme=[bn.add(gum.LabelizedVar(nom,'',2)) for nom in 'sexe daltonisme'.split()]
bn.insertArc(sexe,daltonisme)

bn.cpt(sexe)[:]=[0.5, 0.5]

bn.cpt(daltonisme)[0,:]=[0.08, 0.92]
bn.cpt(daltonisme)[1,:]=[0.005,0.995]

bn.saveBIF("exo1.bif")
for line in open("exo1.bif"):
    print line,

print("for gum.loadBN or gum.saveBN, possible files ext are ="+gum.availableBNExts())
gum.saveBN(bn,"exo1.dsl")
for line in open("exo1.dsl"):
    print line,