Exemplo n.º 1
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata10.txt'))
     self.neteval = evaluator.NetworkEvaluator(
         self.data, 
         network.fromdata(self.data), 
         prior.UniformPrior(self.data.variables.size))
     self.neteval.network.edges.add_many([(1,0),(2,0),(3,0)])
Exemplo n.º 2
0
 def setUp(self):
     a,b,c,d,e = 0,1,2,3,4
     
     self.data = data.fromfile(testfile('testdata9.txt'))
     self.net = network.fromdata(self.data)
     self.net.edges.add_many([(a,c), (b,c), (c,d), (c,e)])
     self.neteval1 = self.neteval_type(self.data, self.net, max_iterations="10*n**2")
Exemplo n.º 3
0
 def test_config2(self):
     try:
         config.read(testfile('config2.txt'))
     except: 
         assert True
     else: 
         assert False
Exemplo n.º 4
0
 def test_tc(self):
     d = data.fromfile(testfile("testdata5.txt"))
     d.discretize()
     tasks = [greedy.GreedyLearner(d) for x in range(5)]
     tc = ipy1.IPython1Controller("127.0.0.1:10113")
     results = tc.run(tasks)
     results = result.merge(results)
     assert isinstance(results, result.LearnerResult)
Exemplo n.º 5
0
def test_arity_checking2():
    try:
        # arity specified is MORE than number of unique values. this is ok.
        dataset = data.fromfile(testfile('testdata7.txt'))
    except:
        assert False
    
    assert [v.arity for v in dataset.variables] == [3,4,3,6]
Exemplo n.º 6
0
def test_arity_checking():
    try:
        # arity specified is less than number of unique values!!
        dataset = data.fromfile(testfile('testdata6.txt'))
    except data.IncorrectArityError:
        assert True
    else:
        assert False
Exemplo n.º 7
0
 def setUp(self):
     dat = data.fromfile(testfile("testdata5.txt"))
     dat.discretize()
     g = greedy.GreedyLearner(dat, max_iterations=100)
     g.run()
     self.result = g.result
     self.tempdir = tempfile.mkdtemp()
     self.result.tohtml(self.tempdir)
Exemplo n.º 8
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata4.txt')) # no tab before variable names
     self.expected_observations = N.array([[0, 0], [1, 1], [1,2]])
     self.expected_missing = N.array([[0, 0], [0, 0], [0, 0]], dtype=bool)
     self.expected_interventions = N.array([[1, 1], [0, 1], [0, 0]], dtype=bool)
     self.expected_varnames = ['shh', 'ptchp']
     self.expected_samplenames = ['sample1', 'sample2', 'sample3']
     self.expected_arities = [2,3]
     self.expected_dtype = N.dtype(int)
Exemplo n.º 9
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata2.txt'))
     self.expected_observations = N.array([[ 0.  ,  0.  ,  1.25,  0.  ],
                                           [ 1.  ,  1.  ,  1.1 ,  1.  ],
                                           [ 1.  ,  2.  ,  0.45,  1.  ]])
     self.expected_dtype = N.dtype(float) # because one continuous variable
     self.expected_varnames = ['shh', 'ptchp', 'smo', 'outcome']
     self.expected_interventions = N.array([[ True,  True, False, False],
                                            [False,  True, False, False],
                                            [False, False, False, False]], dtype=bool)
     self.expected_missing = N.array([[False, False, False, False],
                                      [False, False, False, False],
                                      [False, False, False, False]], dtype=bool)
     self.expected_arities = [2, 3, -1, 2]         
Exemplo n.º 10
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata1.txt'))
     self.expected_observations = N.array([[   2.5,    0. ,    1.7],
                                           [   1.1,    1.7,    2.3],
                                           [   4.2,  999.3,   12. ]])
     self.expected_dtype = N.dtype(float)
     self.expected_varnames = ['var1', 'var2', 'var3']
     self.expected_missing = N.array([[False,  True, False],
                                      [False, False, False],
                                      [False, False, False]], dtype=bool)
     self.expected_interventions = N.array([[ True,  True, False],
                                            [False,  True, False],
                                            [False, False, False]], dtype=bool)
     self.expected_arities = [-1,-1,-1]
Exemplo n.º 11
0
    def setup(self):
        self.tempdir = tempfile.mkdtemp()
        self.outdir = os.path.join(self.tempdir, 'result')

        htmlreport_config = textwrap.dedent("""
        [data]
        filename = %s

        [result]
        format = html
        outdir = %s
        """ % (testfile("testdata12.txt"), self.outdir))
        
        configfile = os.path.join(self.tempdir, "config.txt")
        with file(configfile, 'w') as f:
            f.write(htmlreport_config)
Exemplo n.º 12
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata5m.txt'))
     self.data.discretize()
     self.expected_original = \
         N.array([[ 1.2,  1.4,  2.1,  2.2,  1.1],
                  [ 2.3,  1.1,  2.1,  3.2,  1.3],
                  [ 3.2,  0. ,  1.2,  2.5,  1.6],
                  [ 4.2,  2.4,  3.2,  2.1,  2.8],
                  [ 2.7,  1.5,  0. ,  1.5,  1.1],
                  [ 1.1,  2.3,  2.1,  1.7,  3.2],
                  [ 2.3,  1.1,  4.3,  2.3,  1.1],
                  [ 3.2,  2.6,  1.9,  1.7,  1.1],
                  [ 2.1,  1.5,  3. ,  1.4,  1.1],
                  [ 0. ,  0. ,  0. ,  0. ,  0. ],
                  [ 0. ,  0. ,  0. ,  0. ,  0. ],
                  [ 0. ,  0. ,  0. ,  0. ,  0. ]])
     self.expected_discretized = \
         N.array([[0, 1, 1, 1, 0],
                 [1, 0, 1, 2, 1],
                 [2, 0, 0, 2, 2],
                 [2, 2, 2, 1, 2],
                 [1, 1, 0, 0, 0],
                 [0, 2, 1, 0, 2],
                 [1, 0, 2, 2, 0],
                 [2, 2, 0, 0, 0],
                 [0, 1, 2, 0, 0],
                 [0, 0, 0, 0, 0],
                 [0, 0, 0, 0, 0],
                 [0, 0, 0, 0, 0]])
     self.expected_arities = [3,3,3,3,3]
     self.expected_missing = N.array([[False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [False, False, False, False, False],
                                      [True , True , True , True , True ],
                                      [True , True , True , True , True ],
                                      [True , True , True , True , True ]], 
                                     dtype=bool)
Exemplo n.º 13
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata5.txt'))
     self.data.discretize()
     self.expected_original = \
         N.array([[ 1.2,  1.4,  2.1,  2.2,  1.1],
                  [ 2.3,  1.1,  2.1,  3.2,  1.3],
                  [ 3.2,  0. ,  1.2,  2.5,  1.6],
                  [ 4.2,  2.4,  3.2,  2.1,  2.8],
                  [ 2.7,  1.5,  0. ,  1.5,  1.1],
                  [ 1.1,  2.3,  2.1,  1.7,  3.2],
                  [ 2.3,  1.1,  4.3,  2.3,  1.1],
                  [ 3.2,  2.6,  1.9,  1.7,  1.1],
                  [ 2.1,  1.5,  3. ,  1.4,  1.1]])
     self.expected_discretized = \
         N.array([[0, 1, 1, 1, 0],
                 [1, 0, 1, 2, 1],
                 [2, 0, 0, 2, 2],
                 [2, 2, 2, 1, 2],
                 [1, 1, 0, 0, 0],
                 [0, 2, 1, 0, 2],
                 [1, 0, 2, 2, 0],
                 [2, 2, 0, 0, 0],
                 [0, 1, 2, 0, 0]])
     self.expected_arities = [3,3,3,3,3]
Exemplo n.º 14
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata5.txt'))
     self.data.discretize(excludevars=[0,1])
     self.expected_original = \
         N.array([[ 1.2,  1.4,  2.1,  2.2,  1.1],
                  [ 2.3,  1.1,  2.1,  3.2,  1.3],
                  [ 3.2,  0. ,  1.2,  2.5,  1.6],
                  [ 4.2,  2.4,  3.2,  2.1,  2.8],
                  [ 2.7,  1.5,  0. ,  1.5,  1.1],
                  [ 1.1,  2.3,  2.1,  1.7,  3.2],
                  [ 2.3,  1.1,  4.3,  2.3,  1.1],
                  [ 3.2,  2.6,  1.9,  1.7,  1.1],
                  [ 2.1,  1.5,  3. ,  1.4,  1.1]])
     self.expected_discretized = \
         N.array([[ 1.2,  1.4,  1. ,  1. ,  0. ],
                 [ 2.3,  1.1,  1. ,  2. ,  1. ],
                 [ 3.2,  0. ,  0. ,  2. ,  2. ],
                 [ 4.2,  2.4,  2. ,  1. ,  2. ],
                 [ 2.7,  1.5,  0. ,  0. ,  0. ],
                 [ 1.1,  2.3,  1. ,  0. ,  2. ],
                 [ 2.3,  1.1,  2. ,  2. ,  0. ],
                 [ 3.2,  2.6,  0. ,  0. ,  0. ],
                 [ 2.1,  1.5,  2. ,  0. ,  0. ]])
     self.expected_arities = [-1,-1,3,3,3]
Exemplo n.º 15
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata10.txt'))
     self.ne = evaluator.SmartNetworkEvaluator(
         self.data,
         network.fromdata(self.data))
Exemplo n.º 16
0
 def test_config1(self):
     config.read(testfile('config1.txt'))
Exemplo n.º 17
0
 def setUp(self):
     self.data = data.fromfile(testfile("testdata5.txt")).subset(samples=range(5))
     self.data.discretize()
     self.learner = self.learnertype(self.data)
Exemplo n.º 18
0
 def setUp(self):
     config.set("evaluator.missingdata_evaluator", self.missing_evaluator)
     self.data = data.fromfile(testfile("testdata13.txt"))
     self.learner = self.learnertype(self.data)
Exemplo n.º 19
0
 def setUp(self):
     config.set("evaluator.missingdata_evaluator", "exact")
     self.data = data.fromfile(testfile("testdata13.txt")).subset(samples=range(5))
     self.learner = greedy.GreedyLearner(self.data, max_iterations=10)
Exemplo n.º 20
0
 def setUp(self):
     d = data.fromfile(testfile("testdata5.txt"))
     d.discretize()
     
     self.tc = self.tctype(*self.args)
     self.tasks = [greedy.GreedyLearner(d, max_iterations=100) for i in xrange(6)]
Exemplo n.º 21
0
    def setUp(self):
        d = data.fromfile(testfile("testdata5.txt"))
        d.discretize()

        self.proc = subprocess.Popen("ipcluster -n 2 </dev/null 1>&0 2>&0", shell=True)
        time.sleep(5)
Exemplo n.º 22
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata5.txt'))
     self.data.discretize()
Exemplo n.º 23
0
 def setUp(self):
     self.data = data.fromfile(testfile('testdata10.txt'))
     self.neteval = evaluator.NetworkEvaluator(self.data, network.fromdata(self.data))
     self.neteval.network.edges.add_many([(1,0), (2,0), (3,0)]) # {1,2,3} --> 0
Exemplo n.º 24
0
 def setUp(self):
     self.data = data.fromfile(testfile("greedytest1-200.txt"))
Exemplo n.º 25
0
from pebl2.taskcontroller import xgrid
from pebl2.test import testfile

help = """Test the Xgrid TaskController.

USAGE: test_xgrid.py configfile

You need to provide the configfile for use with XGridController.

###############################################################################
    WARNING for pebl devs: 
        Do NOT put your configfile under svn. 
        It contains sensitve information.
###############################################################################
"""

if len(sys.argv) < 2:
    print help
    sys.exit(1)

config.read(sys.argv[1])
d = data.fromfile(testfile("testdata5.txt"))
d.discretize()

tc = xgrid.XgridController()
results = tc.run([greedy.GreedyLearner(d, max_time=10) for i in xrange(10)])
results = result.merge(results)

print results
print [r.host for r in results.runs]