Exemple #1
0
 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
Exemple #2
0
 def execute(self):
     name = 'AL%d-Iter%d-main' % (self.exp.exp_id, self.iteration.iter_num)
     features_conf = FeaturesConf(
         self.exp.exp_conf.features_conf.input_features,
         self.exp.exp_conf.features_conf.sparse,
         self.exp.exp_conf.features_conf.logger,
         filter_in_f=self.exp.exp_conf.features_conf.filter_in_f,
         filter_out_f=self.exp.exp_conf.features_conf.filter_out_f)
     exp_conf = DiademConf(self.exp.exp_conf.secuml_conf,
                           self.exp.exp_conf.dataset_conf,
                           features_conf,
                           self.exp.exp_conf.annotations_conf,
                           self.model_conf,
                           None,
                           name=name,
                           parent=self.exp.exp_id)
     self.model_exp = DiademExp(exp_conf, session=self.exp.session)
     classifier_type = get_classifier_type(
         self.model_conf.classifier_conf.__class__)
     cv_monitoring = classifier_type == ClassifierType.supervised
     prev_classifier = None
     prev_iter = self.iteration.prev_iter
     if prev_iter is not None:
         prev_classifier = prev_iter.update_model.classifier
     self.model_exp.run(instances=self.iteration.datasets.instances,
                        cv_monitoring=cv_monitoring,
                        init_classifier=prev_classifier)
     self._set_exec_time()
     self.classifier = self.model_exp.get_train_exp().classifier
Exemple #3
0
 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
     factory = classifiers.get_factory()
     naive_bayes_conf = factory.get_default('GaussianNaiveBayes',
                                            optim_conf.num_folds,
                                            optim_conf.n_jobs, multiclass,
                                            self.exp.logger)
     test_conf = UnlabeledLabeledConf(self.exp.logger)
     classification_conf = ClassificationConf(naive_bayes_conf, test_conf,
                                              self.exp.logger)
     features_conf = FeaturesConf(
         self.exp.exp_conf.features_conf.input_features,
         self.exp.exp_conf.features_conf.sparse,
         self.exp.exp_conf.features_conf.logger,
         filter_in_f=self.exp.exp_conf.features_conf.filter_in_f,
         filter_out_f=self.exp.exp_conf.features_conf.filter_out_f)
     exp_conf = DiademConf(self.exp.exp_conf.secuml_conf,
                           self.exp.exp_conf.dataset_conf,
                           features_conf,
                           self.exp.exp_conf.annotations_conf,
                           classification_conf,
                           None,
                           name=name,
                           parent=self.exp.exp_id)
     DiademExp(exp_conf, session=self.exp.session)
     return naive_bayes_conf
Exemple #4
0
 def _create_naive_bayes_conf(self):
     name = '-'.join([
         'AL%d' % (self.exp.exp_id),
         'Iter%d' % (self.iteration.iter_num), 'all', 'NaiveBayes'
     ])
     multiclass_model = self.exp.exp_conf.core_conf.multiclass_model
     classifier_conf = multiclass_model.classifier_conf
     optim_conf = classifier_conf.hyperparam_conf.optim_conf
     multiclass = True
     factory = classifiers.get_factory()
     naive_bayes_conf = factory.get_default('GaussianNaiveBayes',
                                            optim_conf.num_folds,
                                            optim_conf.n_jobs, multiclass,
                                            self.exp.logger)
     test_conf = UnlabeledLabeledConf(self.exp.logger)
     classif_conf = ClassificationConf(naive_bayes_conf, test_conf,
                                       self.exp.logger)
     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,
                classif_conf,
                None,
                name=name,
                parent=self.exp.exp_id)
     return naive_bayes_conf
Exemple #5
0
 def _run_logistic_regression(self):
     name = '-'.join([
         'AL%d' % (self.exp.exp_id),
         'Iter%d' % (self.iteration.iter_num), 'all', 'LogisticRegression'
     ])
     features_conf = FeaturesConf(
         self.exp.exp_conf.features_conf.input_features,
         self.exp.exp_conf.features_conf.sparse,
         self.exp.exp_conf.features_conf.logger,
         filter_in_f=self.exp.exp_conf.features_conf.filter_in_f,
         filter_out_f=self.exp.exp_conf.features_conf.filter_out_f)
     exp_conf = DiademConf(self.exp.exp_conf.secuml_conf,
                           self.exp.exp_conf.dataset_conf,
                           features_conf,
                           self.exp.exp_conf.annotations_conf,
                           self.exp.exp_conf.core_conf.multiclass_model,
                           None,
                           name=name,
                           parent=self.exp.exp_id)
     model_exp = DiademExp(exp_conf, session=self.exp.session)
     model_exp.run(instances=self.iteration.datasets.instances,
                   cv_monitoring=False)
     train_exp = model_exp.get_train_exp()
     test_exp = model_exp.get_detection_exp('test')
     self.lr_predicted_proba = test_exp.predictions.all_probas
     self.lr_predicted_labels = test_exp.predictions.values
     self.lr_class_labels = train_exp.classifier.class_labels
     self.lr_time = train_exp.monitoring.exec_times.total()
     self.lr_time += test_exp.monitoring.exec_time.predictions
Exemple #6
0
 def execute(self):
     name = 'AL%d-Iter%d-main' % (self.exp.exp_id, self.iteration.iter_num)
     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,
                           self.model_conf,
                           name=name,
                           parent=self.exp.exp_id)
     self.model_exp = DiademExp(exp_conf, session=self.exp.session)
     self.model_exp.run(instances=self.iteration.datasets.instances,
                        cv_monitoring=True)
     self._set_exec_time()
     self.classifier = self.model_exp.get_train_exp().classifier
Exemple #7
0
 def _get_multiclass_conf(self):
     conf = self.rcd_conf.classification_conf
     name = '-'.join([
         'AL%d' % self.exp.exp_id,
         'Iter%d' % self.iteration.iter_num, self.label, 'analysis'
     ])
     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,
                           conf,
                           name=name,
                           parent=self.exp.exp_id)
     self.multiclass_exp = DiademExp(exp_conf, session=self.exp.session)
     self.multiclass_exp.create_exp()
     return conf
Exemple #8
0
 def _get_multiclass_conf(self):
     conf = self.rcd_conf.classification_conf
     name = '-'.join(['AL%d' % self.exp.exp_id,
                      'Iter%d' % self.iteration.iter_num,
                      self.label,
                      'analysis'])
     features_conf = FeaturesConf(
             self.exp.exp_conf.features_conf.input_features,
             self.exp.exp_conf.features_conf.sparse,
             self.exp.exp_conf.features_conf.logger,
             filter_in_f=self.exp.exp_conf.features_conf.filter_in_f,
             filter_out_f=self.exp.exp_conf.features_conf.filter_out_f)
     exp_conf = DiademConf(self.exp.exp_conf.secuml_conf,
                           self.exp.exp_conf.dataset_conf,
                           features_conf,
                           self.exp.exp_conf.annotations_conf,
                           conf, None, name=name, parent=self.exp.exp_id)
     self.multiclass_exp = DiademExp(exp_conf, session=self.exp.session)
     return conf