Ejemplo n.º 1
0
# SecuML
# Copyright (C) 2016-2019  ANSSI
#
# SecuML is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# SecuML is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with SecuML. If not, see <http://www.gnu.org/licenses/>.

from secuml.core.conf import register_submodules
from . import algos

register_submodules(algos, algos.get_factory())
Ejemplo n.º 2
0
# SecuML
# Copyright (C) 2016-2018  ANSSI
#
# SecuML is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# SecuML is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with SecuML. If not, see <http://www.gnu.org/licenses/>.

from . import strategies
from secuml.core.conf import register_submodules

register_submodules(strategies, strategies.get_factory())
Ejemplo n.º 3
0
            name += self.classifier_conf.get_exp_name()
        name += self.test_conf.get_exp_name()
        return name

    def fields_to_export(self):
        return [('classifier_conf', exportFieldMethod.obj),
                ('test_conf', exportFieldMethod.obj)]

    @staticmethod
    def gen_parser(parser):
        TestConf.gen_parser(parser)

    @staticmethod
    def from_args(args, logger):
        classifier_conf = classifiers.get_factory().from_args(
            args.model_class, args, logger)
        test_conf = test.get_factory().from_args(args.validation_mode, args,
                                                 logger)
        return ClassificationConf(classifier_conf, test_conf, logger)

    def from_json(conf_json, logger):
        classifier_conf = classifiers.get_factory().from_json(
            conf_json['classifier_conf'], logger)
        test_conf = test.get_factory().from_json(conf_json['test_conf'],
                                                 logger)
        return ClassificationConf(classifier_conf, test_conf, logger)


register_submodules(classifiers, classifiers.get_factory())
register_submodules(test, test.get_factory())
Ejemplo n.º 4
0
            return None
        factory = objective_func.get_factory()
        obj_func_conf = factory.from_json(obj['objective_func'], logger)
        return OptimConf(obj['num_folds'], obj['n_jobs'], obj_func_conf,
                         logger)

    @staticmethod
    def from_args(args, logger):
        factory = objective_func.get_factory()
        if args.multiclass:
            obj_func_conf = factory.from_args('Accuracy', args, logger)
        else:
            obj_func_conf = factory.from_args(args.objective_func, args,
                                              logger)
        return OptimConf(args.num_folds, args.n_jobs, obj_func_conf, logger)

    @staticmethod
    def get_default(num_folds, n_jobs, multiclass, logger):
        if num_folds is None:
            num_folds = 4
        if n_jobs is None:
            n_jobs = 1
        if multiclass:
            scoring = AccuracyConf
        else:
            scoring = RocAucConf
        return OptimConf(num_folds, n_jobs, scoring(logger), logger)


register_submodules(objective_func, objective_func.get_factory())