Esempio n. 1
0
    def testCombinations(self):
        from gaia2.utils import combinations, dictcombinations

        choices = [ [ 1, 2 ],
                    [ 3, 4 ] ]

        combs = [ (1, 3), (1, 4), (2, 3), (2, 4) ]

        self.assertEqual(list(combinations(choices)), combs)

        choices = [ [ 'a', 'b', 'e' ],
                    [ 'c' ],
                    [ 4, 7 ] ]

        combs = [ ('a', 'c', 4), ('a', 'c', 7),
                  ('b', 'c', 4), ('b', 'c', 7),
                  ('e', 'c', 4), ('e', 'c', 7) ]

        self.assertEqual(list(combinations(choices)), combs)

        choices = { 'a': [ 1, 2, 3 ],
                    'b': [ 'frotz' ],
                    'c': [ 2.3, 4.7 ]
                    }

        combs = [ { 'a': 1, 'b': 'frotz', 'c': 2.3 },
                  { 'a': 1, 'b': 'frotz', 'c': 4.7 },
                  { 'a': 2, 'b': 'frotz', 'c': 2.3 },
                  { 'a': 2, 'b': 'frotz', 'c': 4.7 },
                  { 'a': 3, 'b': 'frotz', 'c': 2.3 },
                  { 'a': 3, 'b': 'frotz', 'c': 4.7 } ]

        for r in list(dictcombinations(choices)):
            self.assert_(r in combs)
Esempio n. 2
0
    def updateAllConfigs(self):
        """Compute all the possible config combinations for training & evaluations."""
        self.allconfigs = []
        self.evalconfigs = []

        for classifier, configs in self.conf['classifiers'].items():
            if classifier not in validClassifiers:
                log.warning('Not a valid classifier: %s' % classifier)
                continue

            for conf in configs:
                dconfig = {'classifier': [classifier]}
                dconfig.update(conf)
                self.allconfigs += list(dictcombinations(dconfig))

        for evaluation, configs in self.conf['evaluations'].items():
            if evaluation not in validEvaluations:
                log.warning('Not a valid evaluation: %s' % evaluation)
                continue

            for conf in configs:
                dconfig = {'type': [evaluation]}
                dconfig.update(conf)
                self.evalconfigs += list(dictcombinations(dconfig))
Esempio n. 3
0
    def updateAllConfigs(self):
        """Compute all the possible config combinations for training & evaluations."""
        self.allconfigs = []
        self.evalconfigs = []

        for classifier, configs in self.conf['classifiers'].items():
            if classifier not in validClassifiers:
                log.warning('Not a valid classifier: %s' % classifier)
                continue

            for conf in configs:
                dconfig = { 'classifier': [ classifier ] }
                dconfig.update(conf)
                self.allconfigs += list(dictcombinations(dconfig))

        for evaluation, configs in self.conf['evaluations'].items():
            if evaluation not in validEvaluations:
                log.warning('Not a valid evaluation: %s' % evaluation)
                continue

            for conf in configs:
                dconfig = { 'type': [ evaluation ] }
                dconfig.update(conf)
                self.evalconfigs += list(dictcombinations(dconfig))
Esempio n. 4
0
    def testCombinations(self):
        from gaia2.utils import combinations, dictcombinations

        choices = [[1, 2], [3, 4]]

        combs = [(1, 3), (1, 4), (2, 3), (2, 4)]

        self.assertEqual(list(combinations(choices)), combs)

        choices = [['a', 'b', 'e'], ['c'], [4, 7]]

        combs = [('a', 'c', 4), ('a', 'c', 7), ('b', 'c', 4), ('b', 'c', 7),
                 ('e', 'c', 4), ('e', 'c', 7)]

        self.assertEqual(list(combinations(choices)), combs)

        choices = {'a': [1, 2, 3], 'b': ['frotz'], 'c': [2.3, 4.7]}

        combs = [{
            'a': 1,
            'b': 'frotz',
            'c': 2.3
        }, {
            'a': 1,
            'b': 'frotz',
            'c': 4.7
        }, {
            'a': 2,
            'b': 'frotz',
            'c': 2.3
        }, {
            'a': 2,
            'b': 'frotz',
            'c': 4.7
        }, {
            'a': 3,
            'b': 'frotz',
            'c': 2.3
        }, {
            'a': 3,
            'b': 'frotz',
            'c': 4.7
        }]

        for r in list(dictcombinations(choices)):
            self.assert_(r in combs)