Ejemplo n.º 1
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Learn a detection model. '
         'The ground-truth must be stored in '
         'annotations/ground_truth.csv.')
     ExpConf.generateParser(parser)
     CoreClassificationConf.generateParser(parser)
     models = [
         'LogisticRegression', 'Svc', 'GaussianNaiveBayes', 'DecisionTree',
         'RandomForest', 'GradientBoosting'
     ]
     subparsers = parser.add_subparsers(dest='model_class')
     subparsers.required = True
     factory = ClassifierConfFactory.getFactory()
     for model in models:
         model_parser = subparsers.add_parser(model)
         factory.generateParser(model, model_parser)
         AnnotationsConf.generateParser(
             model_parser,
             required=True,
             message='CSV file containing the annotations of some '
             'or all the instances.')
     ## Add subparser for already trained model
     already_trained = subparsers.add_parser('AlreadyTrained')
     factory.generateParser('AlreadyTrained', already_trained)
     return parser
Ejemplo n.º 2
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Clustering of the data for data exploration.')
     ExpConf.generateParser(parser)
     AnnotationsConf.generateParser(
         parser,
         message='CSV file containing the annotations of some '
         'instances. These annotations are used for '
         'semi-supervised projections.')
     parser.add_argument(
         '--label',
         choices=['all', 'malicious', 'benign'],
         default='all',
         help='The clustering is built from all the instances in the '
         'dataset, or only from the benign or malicious ones. '
         'By default, the clustering is built from all the '
         'instances. The malicious and benign instances are '
         'selected according to the ground-truth stored in '
         'annotations/ground_truth.csv.')
     subparsers = parser.add_subparsers(dest='algo')
     subparsers.required = True
     factory = ClusteringConfFactory.getFactory()
     for algo in factory.getMethods():
         algo_parser = subparsers.add_parser(algo)
         factory.generateParser(algo, algo_parser)
     return parser
Ejemplo n.º 3
0
 def generateParser():
     parser = argparse.ArgumentParser(description='Features Analysis')
     ExpConf.generateParser(parser, filters=False)
     AnnotationsConf.generateParser(parser,
                 required=True,
                 message='CSV file containing the annotations of some or all'
                         ' the instances.')
     return parser
Ejemplo n.º 4
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Rare Category Detection',
         formatter_class=argparse.RawTextHelpFormatter)
     ExpConf.generateParser(parser)
     AnnotationsConf.generateParser(
         parser,
         default='init_annotations.csv',
         required=False,
         message='CSV file containing the initial annotations '
         'used to learn the first supervised detection '
         'model.')
     factory = ActiveLearningConfFactory.getFactory()
     factory.generateParser('RareCategoryDetection', parser)
     return parser
Ejemplo n.º 5
0
 def __init__(self,
              secuml_conf,
              dataset_conf,
              features_conf,
              annotations_conf,
              core_conf,
              experiment_name=None,
              parent=None):
     ExpConf.__init__(self,
                      secuml_conf,
                      dataset_conf,
                      features_conf,
                      annotations_conf,
                      core_conf,
                      experiment_name=experiment_name,
                      parent=parent)
     self.test_exp_conf = None
Ejemplo n.º 6
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Projection of the data for data visualization.')
     ExpConf.generateParser(parser)
     AnnotationsConf.generateParser(
         parser,
         message='CSV file containing the annotations of some'
         ' instances. These annotations are used for '
         'semi-supervised projections.')
     algos = ['Pca', 'Rca', 'Lda', 'Lmnn', 'Nca', 'Itml']
     subparsers = parser.add_subparsers(dest='algo')
     subparsers.required = True
     factory = ProjectionConfFactory.getFactory()
     for algo in algos:
         algo_parser = subparsers.add_parser(algo)
         factory.generateParser(algo, algo_parser)
     return parser
Ejemplo n.º 7
0
 def __init__(self,
              secuml_conf,
              dataset_conf,
              features_conf,
              annotations_conf,
              core_conf,
              experiment_name=None,
              parent=None,
              label='all'):
     ExpConf.__init__(self,
                      secuml_conf,
                      dataset_conf,
                      features_conf,
                      annotations_conf,
                      core_conf,
                      experiment_name=experiment_name,
                      parent=parent)
     self.label = label
Ejemplo n.º 8
0
 def fromArgs(args):
     secuml_conf = ExpConf.common_from_args(args)
     dataset_conf = DatasetConf.fromArgs(args, secuml_conf.logger)
     features_conf = FeaturesConf.fromArgs(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,
                                 experiment_name=args.exp_name)
Ejemplo n.º 9
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Active Learning',
         formatter_class=argparse.RawTextHelpFormatter)
     ExpConf.generateParser(parser)
     AnnotationsConf.generateParser(
         parser,
         default='init_annotations.csv',
         required=False,
         message='CSV file containing the initial annotations '
         'used to learn the first supervised detection '
         'model.')
     subparsers = parser.add_subparsers(dest='strategy')
     subparsers.required = True
     factory = ActiveLearningConfFactory.getFactory()
     strategies = factory.getMethods()
     for strategy in strategies:
         strategy_parser = subparsers.add_parser(strategy)
         factory.generateParser(strategy, strategy_parser)
     return parser
Ejemplo n.º 10
0
 def fromArgs(args):
     secuml_conf = ExpConf.common_from_args(args)
     dataset_conf = DatasetConf.fromArgs(args, secuml_conf.logger)
     features_conf = FeaturesConf.fromArgs(args, secuml_conf.logger)
     annotations_conf = AnnotationsConf(args.annotations_file, None,
                                        secuml_conf.logger)
     factory = ActiveLearningConfFactory.getFactory()
     core_conf = factory.fromArgs(args.strategy, args, secuml_conf.logger)
     return ActiveLearningConf(secuml_conf,
                               dataset_conf,
                               features_conf,
                               annotations_conf,
                               core_conf,
                               experiment_name=args.exp_name)
Ejemplo n.º 11
0
 def fromArgs(args):
     secuml_conf = ExpConf.common_from_args(args)
     dataset_conf = DatasetConf.fromArgs(args, secuml_conf.logger)
     features_conf = FeaturesConf.fromArgs(args, secuml_conf.logger)
     annotations_conf = AnnotationsConf(args.annotations_file, None,
                                        secuml_conf.logger)
     factory = ClusteringConfFactory.getFactory()
     core_conf = factory.fromArgs(args.algo, args, secuml_conf.logger)
     conf = ClusteringConf(secuml_conf,
                           dataset_conf,
                           features_conf,
                           annotations_conf,
                           core_conf,
                           experiment_name=args.exp_name,
                           label=args.label)
     return conf
Ejemplo n.º 12
0
 def fromArgs(args):
     secuml_conf = ExpConf.common_from_args(args)
     already_trained = None
     if args.model_class != 'AlreadyTrained':
         core_conf = CoreClassificationConf.fromArgs(
             args, True, secuml_conf.logger)
         annotations_conf = AnnotationsConf(args.annotations_file, None,
                                            secuml_conf.logger)
     else:
         already_trained = args.model_exp_id
         core_conf = CoreClassificationConf.fromArgs(
             args, False, secuml_conf.logger)
         annotations_conf = AnnotationsConf(None, None, secuml_conf.logger)
     dataset_conf = DatasetConf.fromArgs(args, secuml_conf.logger)
     features_conf = FeaturesConf.fromArgs(args, secuml_conf.logger)
     return ClassificationConf(secuml_conf,
                               dataset_conf,
                               features_conf,
                               annotations_conf,
                               core_conf,
                               experiment_name=args.exp_name,
                               already_trained=already_trained)
Ejemplo n.º 13
0
 def fieldsToExport(self):
     fields = ExpConf.fieldsToExport(self)
     fields.extend([('test_exp_conf', exportFieldMethod.obj)])
     return fields
Ejemplo n.º 14
0
 def fieldsToExport(self):
     fields = ExpConf.fieldsToExport(self)
     fields.extend([('label', exportFieldMethod.primitive)])
     return fields
Ejemplo n.º 15
0
 def _get_exp_name(self):
     name = ''
     if self.already_trained is not None:
         name += 'AlreadyTrained_exp%i' % self.already_trained
     name += ExpConf._get_exp_name(self)
     return name
Ejemplo n.º 16
0
 def fieldsToExport(self):
     fields = ExpConf.fieldsToExport(self)
     fields.extend([('already_trained', exportFieldMethod.primitive)])
     fields.extend([('test_exp_conf', exportFieldMethod.obj)])
     return fields