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 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 _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
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 _rcd_conf(args, logger): factory = classifiers.get_factory() classifier_conf = factory.get_default('LogisticRegression', None, None, True, logger) classif_conf = ClassificationConf(classifier_conf, UnlabeledLabeledConf(logger), logger) return RcdStrategyConf(classif_conf, args.cluster_strategy, args.num_annotations, 'uniform', logger)
def _get_lr_conf(self, validation_conf, logger, multiclass=False): factory = classifiers.get_factory() classifier_conf = factory.get_default('LogisticRegression', None, None, multiclass, 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 from_args(self, method, args, logger): validation_conf = None if args.validation_datasets is not None: validation_conf = ValidationDatasetsConf.from_args(args, logger) class_ = self.get_class(method) main_model_type = class_.main_model_type() main_model_conf = None if main_model_type is not None: factory = classifiers.get_factory() args.multiclass = main_model_type == 'multiclass' classifier_conf = factory.from_args(args.model_class, args, logger) test_conf = UnlabeledLabeledConf(logger) main_model_conf = ClassificationConf( classifier_conf, test_conf, logger, validation_conf=validation_conf) return class_.from_args(args, main_model_conf, validation_conf, logger)