def _create_detection_exp(self, kind, classifier_conf, fold_id=None): diadem_id = self.exp_conf.exp_id exp_name = 'DIADEM_%i_Detection_%s' % (diadem_id, kind) if fold_id is not None: exp_name = '%s_fold_%i' % (exp_name, fold_id) secuml_conf = self.exp_conf.secuml_conf logger = secuml_conf.logger if kind == 'validation': dataset_conf = DatasetConf(self.exp_conf.dataset_conf.project, self.validation_conf.test_dataset, self.exp_conf.secuml_conf.logger) annotations_conf = AnnotationsConf('ground_truth.csv', None, logger) elif kind == 'test' and self.test_conf.method == 'dataset': dataset_conf = DatasetConf(self.exp_conf.dataset_conf.project, self.test_conf.test_dataset, self.exp_conf.secuml_conf.logger) annotations_conf = AnnotationsConf('ground_truth.csv', None, logger) else: dataset_conf = self.exp_conf.dataset_conf annotations_conf = self.exp_conf.annotations_conf features_conf = self.exp_conf.features_conf test_exp_conf = DetectionConf(secuml_conf, dataset_conf, features_conf, annotations_conf, self._get_alerts_conf(fold_id), name=exp_name, parent=diadem_id, fold_id=fold_id, kind=kind) return DetectionExp(test_exp_conf, session=self.session)
def from_args(args): secuml_conf = ExpConf.common_from_args(args) already_trained = None core_conf = ClassificationConf.from_args(args, secuml_conf.logger) if args.model_class != 'AlreadyTrained': annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) else: already_trained = args.model_exp_id annotations_conf = AnnotationsConf(None, None, secuml_conf.logger) dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) return DiademConf(secuml_conf, dataset_conf, features_conf, annotations_conf, core_conf, name=args.exp_name, already_trained=already_trained)
def _create_test_exp(self, fold_id=None): diadem_id = self.exp_conf.exp_id exp_name = 'DIADEM_%i_Test' % diadem_id if fold_id is not None: exp_name = '%s_fold_%i' % (exp_name, fold_id) secuml_conf = self.exp_conf.secuml_conf logger = secuml_conf.logger if self.test_conf.method == 'dataset': dataset_conf = DatasetConf(self.exp_conf.dataset_conf.project, self.test_conf.test_dataset, self.exp_conf.secuml_conf.logger) annotations_conf = AnnotationsConf('ground_truth.csv', None, logger) else: dataset_conf = self.exp_conf.dataset_conf annotations_conf = self.exp_conf.annotations_conf features_conf = self.exp_conf.features_conf test_exp_conf = TestConf(secuml_conf, dataset_conf, features_conf, annotations_conf, self.exp_conf.core_conf.classifier_conf, name=exp_name, parent=diadem_id, fold_id=fold_id, kind='test') return TestExp(test_exp_conf, alerts_conf=self._get_alerts_conf(fold_id), session=self.session)
def from_args(args): secuml_conf = ExpConf.secuml_conf_from_args(args) classif_conf = ClassificationConf.from_args(args, secuml_conf.logger) model_class = classifiers.get_factory().get_class(args.model_class) classifier_type = get_classifier_type(model_class) if classifier_type in [ ClassifierType.supervised, ClassifierType.semisupervised ]: annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) else: annotations_conf = AnnotationsConf(None, None, secuml_conf.logger) already_trained = None if args.model_class == 'AlreadyTrained': already_trained = args.model_exp_id alerts_conf = AlertsConf.from_args(args, secuml_conf.logger) if (classifier_type == ClassifierType.unsupervised and alerts_conf.classifier_conf is not None): raise InvalidInputArguments('Supervised classification of the ' 'alerts is not supported for ' 'unsupervised model classes. ') if classif_conf.classifier_conf.multiclass: if alerts_conf.with_analysis(): raise InvalidInputArguments('Alerts analysis is not supported ' 'for multiclass models. ') else: alerts_conf = None if (classif_conf.test_conf.method == 'dataset' and classif_conf.test_conf.streaming and alerts_conf.with_analysis()): raise InvalidInputArguments('Alerts analysis is not supported ' 'in streaming mode. ') dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) if (features_conf.sparse and not classif_conf.classifier_conf.accept_sparse): raise InvalidInputArguments('%s does not support sparse ' 'features. ' % args.model_class) return DiademConf(secuml_conf, dataset_conf, features_conf, annotations_conf, classif_conf, alerts_conf, name=args.exp_name, already_trained=already_trained, no_training_detection=args.no_training_detection)
def from_args(args): secuml_conf = ExpConf.secuml_conf_from_args(args) logger = secuml_conf.logger dataset_conf = DatasetConf.from_args(args, logger) features_conf = FeaturesConf.from_args(args, logger) annotations_conf = AnnotationsConf(args.annotations_file, None, logger) core_conf = strategies_conf.get_factory().from_args('Rcd', args, logger) return RcdConf(secuml_conf, dataset_conf, features_conf, annotations_conf, core_conf, name=args.exp_name)
def from_args(args): secuml_conf = ExpConf.common_from_args(args) dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) core_conf = projection_conf.get_factory().from_args(args.algo, args, secuml_conf.logger) return ProjectionConf(secuml_conf, dataset_conf, features_conf, annotations_conf, core_conf, name=args.exp_name)
def from_args(args): secuml_conf = ExpConf.secuml_conf_from_args(args) classif_conf = ClassificationConf.from_args(args, secuml_conf.logger) model_class = classifiers.get_factory().get_class(args.model_class) classifier_type = get_classifier_type(model_class) if classifier_type in [ClassifierType.supervised, ClassifierType.semisupervised]: annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) else: annotations_conf = AnnotationsConf(None, None, secuml_conf.logger) already_trained = None if args.model_class == 'AlreadyTrained': already_trained = args.model_exp_id dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) return DiademConf(secuml_conf, dataset_conf, features_conf, annotations_conf, classif_conf, name=args.exp_name, already_trained=already_trained)
def from_args(args): secuml_conf = ExpConf.common_from_args(args) dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) return FeaturesAnalysisConf(secuml_conf, dataset_conf, features_conf, annotations_conf, None, name=args.exp_name)
def from_args(args): secuml_conf = ExpConf.secuml_conf_from_args(args) dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) core_conf = strategies_conf.get_factory().from_args(args.strategy, args, secuml_conf.logger) return ActiveLearningConf(secuml_conf, dataset_conf, features_conf, annotations_conf, core_conf, name=args.exp_name)
def from_args(args): secuml_conf = ExpConf.secuml_conf_from_args(args) dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) core_conf = clustering_conf.get_factory().from_args( args.algo, args, secuml_conf.logger) conf = ClusteringConf(secuml_conf, dataset_conf, features_conf, annotations_conf, core_conf, name=args.exp_name, label=args.label) return conf
def from_args(args): if args.annotations_file is None and args.multiclass: raise InvalidInputArguments('--annotations <file> is required. ' 'An annotation file must be specified ' 'to group the instances according to ' 'their families.') secuml_conf = ExpConf.secuml_conf_from_args(args) dataset_conf = DatasetConf.from_args(args, secuml_conf.logger) features_conf = FeaturesConf.from_args(args, secuml_conf.logger) annotations_conf = AnnotationsConf(args.annotations_file, None, secuml_conf.logger) return FeaturesAnalysisConf(secuml_conf, dataset_conf, features_conf, annotations_conf, args.multiclass, name=args.exp_name)
def _create_detection_conf(self, kind, classifier_conf, fold_id=None): diadem_id = self.exp_conf.exp_id exp_name = 'DIADEM_%i_Detection_%s' % (diadem_id, kind) if fold_id is not None: exp_name = '%s_fold_%i' % (exp_name, fold_id) secuml_conf = self.exp_conf.secuml_conf logger = secuml_conf.logger if (kind == 'validation' or (kind == 'test' and self.test_conf.method == 'datasets')): validation_conf = getattr(self, '%s_conf' % kind) annotations_conf = AnnotationsConf('ground_truth.csv', None, logger) features_conf = self.exp_conf.features_conf if validation_conf.streaming: stream_batch = validation_conf.stream_batch features_conf = features_conf.copy_streaming(stream_batch) dataset_confs = [ DatasetConf(self.exp_conf.dataset_conf.project, test_dataset, self.exp_conf.secuml_conf.logger) for test_dataset in validation_conf.validation_datasets ] else: dataset_confs = [self.exp_conf.dataset_conf] annotations_conf = self.exp_conf.annotations_conf features_conf = self.exp_conf.features_conf alerts_conf = None if fold_id is None and kind != 'train': alerts_conf = self.exp_conf.alerts_conf return [ DetectionConf(secuml_conf, dataset_conf, features_conf, annotations_conf, alerts_conf, name=exp_name, parent=diadem_id, fold_id=fold_id, kind=kind) for dataset_conf in dataset_confs ]