コード例 #1
0
 def gen_parser(parser, model_class, multiclass=True):
     if multiclass:
         parser.add_argument('--multiclass', default=False,
                             action='store_true',
                             help='The classifier is trained on the '
                                  'families instead of the binary labels.')
     HyperparamConf.gen_parser(parser, model_class, False)
コード例 #2
0
 def gen_main_model_parser(parser):
     group = parser.add_argument_group('Classification model parameters')
     models = classifiers.get_factory().get_methods(supervised=True)
     group.add_argument('--model-class',
                        choices=models,
                        default='LogisticRegression',
                        help='Model class trained at each iteration. '
                        'Default: LogisticRegression.')
     HyperparamConf.gen_parser(group, None, True, subgroup=False)
コード例 #3
0
ファイル: categories.py プロジェクト: tuantmb/SecuML
 def get_naive_bayes_conf(self):
     name = '-'.join([
         'AL%d' % self.exp.exp_id,
         'Iter%d' % self.iteration.iter_num, 'all', 'NaiveBayes'
     ])
     classifier_conf = self.exp.exp_conf.core_conf.classifier_conf
     optim_conf = classifier_conf.hyperparam_conf.optim_conf
     multiclass = True
     hyperparam_conf = HyperparamConf.get_default(
         optim_conf.num_folds, optim_conf.n_jobs, multiclass,
         GaussianNaiveBayesConf._get_hyper_desc(), self.exp.logger)
     naive_bayes_conf = GaussianNaiveBayesConf(multiclass, hyperparam_conf,
                                               self.exp.logger)
     test_conf = UnlabeledLabeledConf(self.exp.logger, None)
     classification_conf = ClassificationConf(naive_bayes_conf, test_conf,
                                              self.exp.logger)
     exp_conf = DiademConf(self.exp.exp_conf.secuml_conf,
                           self.exp.exp_conf.dataset_conf,
                           self.exp.exp_conf.features_conf,
                           self.exp.exp_conf.annotations_conf,
                           classification_conf,
                           name=name,
                           parent=self.exp.exp_id)
     naive_bayes_exp = DiademExp(exp_conf, session=self.exp.session)
     naive_bayes_exp.create_exp()
     return naive_bayes_conf
コード例 #4
0
ファイル: gornitz.py プロジェクト: zzszmyf/SecuML
 def _get_main_model_conf(self, validation_conf, logger):
     hyperparam_conf = HyperparamConf.get_default(None, None, False, None,
                                                  logger)
     classifier_conf = SssvddConf(hyperparam_conf, logger)
     return ClassificationConf(classifier_conf,
                               UnlabeledLabeledConf(logger),
                               logger,
                               validation_conf=validation_conf)
コード例 #5
0
 def from_args(self, method, args, logger):
     class_ = self.methods[method + 'Conf']
     hyper_conf = None
     if method != 'AlreadyTrained':
         is_supervised = get_classifier_type(class_) == \
                                         ClassifierType.supervised
         hyper_conf = HyperparamConf.from_args(args, class_, is_supervised,
                                               logger)
     return class_.from_args(args, hyper_conf, logger)
コード例 #6
0
ファイル: __init__.py プロジェクト: ryanbekabe/SecuML
 def from_args(self, method, args, logger):
     class_ = self.methods[method + 'Conf']
     hyper_conf = None
     if method != 'AlreadyTrained':
         hyper_conf = HyperparamConf.from_args(args,
                                               class_._get_hyper_desc(),
                                               class_.is_supervised(),
                                               logger)
     return class_.from_args(args, hyper_conf, logger)
コード例 #7
0
 def _get_lr_conf(self, validation_conf, logger, multiclass=False):
     hyperparam_conf = HyperparamConf.get_default(
                                 None, None, multiclass,
                                 LogisticRegressionConf._get_hyper_desc(),
                                 logger)
     core_conf = LogisticRegressionConf(multiclass, 'liblinear',
                                        hyperparam_conf, logger)
     return ClassificationConf(core_conf,
                               UnlabeledLabeledConf(logger, None),
                               logger, validation_conf=validation_conf)
コード例 #8
0
ファイル: ilab.py プロジェクト: textSolver34761/SecuML
def _rcd_conf(args, logger):
    hyperparam_conf = HyperparamConf.get_default(
                                None, None, True,
                                LogisticRegressionConf._get_hyper_desc(),
                                logger)
    core_conf = LogisticRegressionConf(True, 'liblinear', hyperparam_conf,
                                       logger)
    classif_conf = ClassificationConf(core_conf,
                                      UnlabeledLabeledConf(logger, None),
                                      logger)
    return RcdStrategyConf(classif_conf, args.cluster_strategy,
                           args.num_annotations, 'uniform', logger)
コード例 #9
0
 def _train_multiclass(self, train_instances):
     # Multi-class model
     num_folds = None
     n_jobs = None
     hyperparam_conf = self.test_exp.classifier.conf.hyperparam_conf
     if hyperparam_conf is not None:
         optim_conf = hyperparam_conf.optim_conf
         if optim_conf is not None:
             num_folds = optim_conf.num_folds
             n_jobs = optim_conf.n_jobs
     hyperparam_conf = HyperparamConf.get_default(
         num_folds, n_jobs, True, LogisticRegressionConf._get_hyper_desc(),
         self.alerts_conf.logger)
     core_conf = LogisticRegressionConf(True, 'liblinear', hyperparam_conf,
                                        self.alerts_conf.logger)
     model = core_conf.model_class(core_conf)
     # Training
     model.training(train_instances)
     return model
コード例 #10
0
 def get_default(model_class, num_folds, n_jobs, multiclass, logger):
     class_ = get_factory().get_class(model_class)
     hyper_conf = HyperparamConf.get_default(num_folds, n_jobs, multiclass,
                                             class_, logger)
     return class_(multiclass, hyper_conf, logger)
コード例 #11
0
 def from_json(self, obj, logger):
     class_ = self.methods[obj['__type__']]
     hyper_conf = HyperparamConf.from_json(obj['hyperparam_conf'], class_,
                                           logger)
     return class_.from_json(obj['multiclass'], hyper_conf, obj, logger)
コード例 #12
0
 def gen_parser(parser, model_class):
     HyperparamConf.gen_parser(parser, model_class, False)
コード例 #13
0
ファイル: __init__.py プロジェクト: tuantmb/SecuML
 def gen_parser(parser, model_class):
     parser.add_argument('--multiclass', default=False, action='store_true')
     HyperparamConf.gen_parser(parser, model_class, False)
コード例 #14
0
ファイル: __init__.py プロジェクト: ryanbekabe/SecuML
 def gen_parser(parser, hyperparam_desc):
     HyperparamConf.gen_parser(parser, hyperparam_desc, False)
コード例 #15
0
ファイル: __init__.py プロジェクト: ryanbekabe/SecuML
 def gen_parser(parser, hyperparam_desc):
     parser.add_argument('--multiclass', default=False, action='store_true')
     HyperparamConf.gen_parser(parser, hyperparam_desc, True)