Ejemplo n.º 1
0
 def setExperimentFromArgs(self, args):
     factory = ClusteringConfFactory.getFactory()
     conf = factory.fromArgs(args.algo, args, logger=self.logger)
     self.setConf(conf,
                  args.features_file,
                  annotations_filename=args.annotations_file)
     self.export()
Ejemplo n.º 2
0
 def fromJson(obj, secuml_conf):
     conf = ClusteringConfFactory.getFactory().fromJson(obj['conf'])
     experiment = ClusteringExperiment(secuml_conf)
     experiment.initExperiment(obj['project'], obj['dataset'],
                               create=False)
     Experiment.expParamFromJson(experiment, obj, conf)
     return experiment
Ejemplo n.º 3
0
 def fromJson(obj, logger=None):
     clustering_conf = ClusteringConfFactory.getFactory().fromJson(
         obj['clustering_conf'], logger=logger)
     conf = AlertsConfiguration(obj['num_max_alerts'],
                                obj['detection_threshold'],
                                clustering_conf,
                                logger=logger)
     return conf
Ejemplo n.º 4
0
 def setExperimentFromArgs(self, args):
     self.initExperiment(args.project, args.dataset,
                         experiment_name=args.exp_name)
     factory = ClusteringConfFactory.getFactory()
     conf = factory.fromArgs(args.algo, args, logger=self.logger)
     self.setConf(conf, args.features_file,
                  annotations_filename=args.annotations_file)
     self.export()
Ejemplo n.º 5
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Clustering of the data for data exploration.')
     Experiment.projectDatasetFeturesParser(parser)
     algos = ['Kmeans', 'GaussianMixture']
     subparsers = parser.add_subparsers(dest='algo')
     factory = ClusteringConfFactory.getFactory()
     for algo in algos:
         algo_parser = subparsers.add_parser(algo)
         factory.generateParser(algo, algo_parser)
     return parser
Ejemplo n.º 6
0
def generateAlertConfFromArgs(args):
    params = {}
    params['num_clusters'] = args.num_clusters
    params['num_results'] = None
    params['projection_conf'] = None
    params['label'] = 'all'
    clustering_conf = ClusteringConfFactory.getFactory().fromParam(
        args.clustering_algo, params)
    alerts_conf = AlertsConfiguration(args.top_n_alerts,
                                      args.detection_threshold,
                                      clustering_conf)
    return alerts_conf
Ejemplo n.º 7
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Clustering of the data for data exploration.')
     Experiment.projectDatasetFeturesParser(parser)
     subparsers = parser.add_subparsers(dest='algo')
     subparsers.required = True
     factory = ClusteringConfFactory.getFactory()
     algos = factory.getAlgorithms()
     for algo in algos:
         algo_parser = subparsers.add_parser(algo)
         factory.generateParser(algo, algo_parser)
     return parser
Ejemplo n.º 8
0
 def generateAlreadyTrainedConf(self, factory, args, logger):
     conf_filename = self.checkAlreadyTrainedConf(args)
     with open(conf_filename, 'r') as f:
         conf_json = json.load(f)
         conf = factory.fromJson(conf_json['classification_conf'],
                                 logger=logger)
         params = {}
         params['num_clusters'] = args.num_clusters
         params['num_results'] = None
         params['projection_conf'] = None
         params['label'] = 'all'
         clustering_conf = ClusteringConfFactory.getFactory().fromParam(
             args.clustering_algo, params, logger=logger)
         alerts_conf = AlertsConfiguration(args.top_n_alerts,
                                           args.detection_threshold,
                                           clustering_conf,
                                           logger=logger)
         test_conf = ValidationDatasetConf(args.validation_dataset,
                                           alerts_conf=alerts_conf,
                                           logger=logger)
         conf.test_conf = test_conf
     return conf