def test_config2(self): try: config.read(testfile('config2.txt')) except: assert True else: assert False
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")
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)])
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)
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]
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
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]
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)
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)
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")
def test_example1(self): outdir = os.path.join(self.tmpdir, "example1-result") dataset = data.fromfile(testfile("pebl-tutorial-data1.txt")) dataset.discretize() learner = greedy.GreedyLearner(dataset) ex1result = learner.run() ex1result.tohtml(outdir) assert os.path.exists(os.path.join(outdir, 'index.html'))
def setUp(self): self.data = data.fromfile(testfile('testdata3.txt')) 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)
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]
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]
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]
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)
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]
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)
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)
def test_example1_configfile(self): configfile = os.path.join(self.tmpdir, 'config1.txt') outdir = os.path.join(self.tmpdir, "example1-result-2") configstr = textwrap.dedent(""" [data] filename = %s discretize = 3 [learner] type = greedy.GreedyLearner [result] format = html outdir = %s """ % (testfile("pebl-tutorial-data1.txt"), outdir)) with file(configfile, 'w') as f: f.write(configstr) pebl_script.run(configfile) assert os.path.exists(os.path.join(outdir, 'data', 'result.data.js'))
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]
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]
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]
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]
def setUp(self): self.data = data.fromfile(testfile("greedytest1-200.txt"))
def setUp(self): self.data = data.fromfile(testfile('testdata5.txt')) self.data.discretize()
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)]
def setUp(self): self.data = data.fromfile(testfile('testdata10.txt')) self.ne = evaluator.SmartNetworkEvaluator( self.data, network.fromdata(self.data))
def setUp(self): self.data = data.fromfile(testfile('testdata10.txt')) self.ne = evaluator.SmartNetworkEvaluator(self.data, network.fromdata(self.data))
def test_config1(self): config.read(testfile('config1.txt'))
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
def setUp(self): self.data = data.fromfile(testfile('testdata5.txt')).subset(samples=range(5)) self.data.discretize() self.learner = self.learnertype(self.data)
def setUp(self): config.set('evaluator.missingdata_evaluator', self.missing_evaluator) self.data = data.fromfile(testfile('testdata13.txt')) self.learner = self.learnertype(self.data)
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)
def setUp(self): self.data = data.fromfile( testfile('testdata5.txt')).subset(samples=range(5)) self.data.discretize() self.learner = self.learnertype(self.data)
from pebl.learner import greedy from pebl.taskcontroller import ec2 from pebl.test import testfile help = """Test the EC2 TaskController. USAGE: test_ec2.py configfile You need to provide the configfile for use with EC2Controller. ############################################################################### 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) d = data.fromfile(testfile("testdata5.txt")) d.discretize() tc = ec2.EC2Controller(config=sys.argv[1], min_count=3) 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]
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
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)])
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)
from pebl.taskcontroller import xgrid from pebl.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]
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)