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
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)
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)
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)
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
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)