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
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
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
def _create_clustering_exp(self, core_clustering_conf): exp_conf = self.test_exp.exp_conf features_conf = FeaturesConf( exp_conf.features_conf.input_features, exp_conf.features_conf.sparse, exp_conf.features_conf.logger, filter_in_f=exp_conf.features_conf.filter_in_f, filter_out_f=exp_conf.features_conf.filter_out_f) conf = ClusteringConf(exp_conf.secuml_conf, exp_conf.dataset_conf, features_conf, exp_conf.annotations_conf, core_clustering_conf, name='Alerts_%i' % exp_conf.exp_id, parent=exp_conf.exp_id) return AlertsClusteringExp(conf, self.test_exp.exp_conf.parent, create=True, session=self.test_exp.session)
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
def _create_clustering_exp(self): core_conf = CoreClusteringConf(self.exp.exp_conf.logger, self.categories.num_categories) name = '-'.join(['AL%d' % self.exp.exp_id, 'Iter%d' % self.iteration.iter_num, self.label, 'clustering']) 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 = ClusteringConf(self.exp.exp_conf.secuml_conf, self.exp.exp_conf.dataset_conf, features_conf, self.exp.exp_conf.annotations_conf, core_conf, name=name, parent=self.exp.exp_id) clustering_exp = ClusteringExperiment(exp_conf, session=self.exp.session) return clustering_exp
def create_exp(self): Experiment.create_exp(self) # create projection experiment self.projection_exp = None if self.exp_conf.core_conf is None: return projection_core_conf = self.exp_conf.core_conf.projection_conf if projection_core_conf is not None: features_conf = FeaturesConf( self.exp_conf.features_conf.input_features, self.exp_conf.secuml_conf.logger) projection_conf = ProjectionConf(self.exp_conf.secuml_conf, self.exp_conf.dataset_conf, features_conf, self.exp_conf.annotations_conf, projection_core_conf, name='-'.join( [self.exp_conf.name, 'proj']), parent=self.exp_id) self.projection_exp = ProjectionExperiment(projection_conf, session=self.session)