Exemplo n.º 1
0
 def gen_parser():
     parser = argparse.ArgumentParser(
         description='Projection of the data for data visualization.')
     ExpConf.gen_parser(parser)
     AnnotationsConf.gen_parser(
         parser,
         message='CSV file containing the annotations of some'
         ' instances. These annotations are used for '
         'semi-supervised projections.')
     subparsers = parser.add_subparsers(dest='algo')
     subparsers.required = True
     for algo in projection_conf.get_factory().get_methods():
         algo_parser = subparsers.add_parser(algo)
         projection_conf.get_factory().gen_parser(algo, algo_parser)
     return parser
Exemplo n.º 2
0
 def proj_conf_from_args(args, logger):
     if (not hasattr(args, 'projection_algo')
             or args.projection_algo is None):
         return None
     proj_factory = projection_conf.get_factory()
     proj_conf = proj_factory.from_args(args.projection_algo, args, logger)
     return proj_conf
Exemplo n.º 3
0
 def gen_parser(parser):
     # Clustering arguments
     parser.add_argument('--num-clusters',
                         type=int,
                         help='''Number of clusters. Default: 4.''',
                         default=4)
     # Projection parameters
     projection_group = parser.add_argument_group('Projection parameters')
     projection_group.add_argument(
             '--projection-algo',
             choices=projection_conf.get_factory().get_methods() + [None],
             default=None,
             help='''Projection performed before building the clustering.
                     By default the instances are not projected.''')
     projection_group.add_argument(
             '--multiclass',
             action='store_true',
             default=False,
             help='''When specified, the semi-supervision is based on
                     the families instead of the binary labels.
                     Useless if an unsupervised projection method is
                     used.''')
     projection_group.add_argument(
                         '--num-components',
                         type=int,
                         default=None,
                         help='''Number of components. Default: None,
                                 the number of components is set to the
                                 number of input features. ''')
Exemplo n.º 4
0
 def from_json(self, obj, logger):
     proj_conf = None
     if obj['projection_conf'] is not None:
         proj_factory = projection_conf.get_factory()
         proj_conf = proj_factory.from_json(obj['projection_conf'], logger)
     class_ = self.methods[obj['__type__']]
     return class_.from_json(obj, proj_conf, logger)
Exemplo n.º 5
0
 def gen_parser():
     parser = argparse.ArgumentParser(
         description='Projection of the data for data visualization.')
     ExpConf.gen_parser(parser)
     AnnotationsConf.gen_parser(
         parser,
         message='''CSV file containing the annotations of some
                         instances, or GROUND_TRUTH to use the ground
                         truth annotations stored in idents.csv.
                         These annotations are used for semi-supervised
                         projections and are displayed in the GUI.''')
     subparsers = parser.add_subparsers(dest='algo')
     subparsers.required = True
     for algo in projection_conf.get_factory().get_methods():
         algo_parser = subparsers.add_parser(algo)
         projection_conf.get_factory().gen_parser(algo, algo_parser)
     return parser
Exemplo n.º 6
0
 def from_args(self, method, args, logger):
     if (not hasattr(args, 'projection_algo')
             or args.projection_algo is None):
         proj_conf = None
     else:
         proj_factory = projection_conf.get_factory()
         proj_conf = proj_factory.from_args(args.projection_algo, args,
                                            logger)
     class_ = self.methods[method + 'Conf']
     return class_.from_args(args, proj_conf, logger)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 def from_json(conf_json, secuml_conf):
     dataset_conf = DatasetConf.from_json(conf_json['dataset_conf'],
                                          secuml_conf.logger)
     features_conf = FeaturesConf.from_json(conf_json['features_conf'],
                                            secuml_conf.logger)
     annotations_conf = AnnotationsConf.from_json(
                                               conf_json['annotations_conf'],
                                               secuml_conf.logger)
     core_conf = projection_conf.get_factory().from_json(
                                                 conf_json['core_conf'],
                                                 secuml_conf.logger)
     conf = ProjectionConf(secuml_conf, dataset_conf, features_conf,
                           annotations_conf, core_conf,
                           name=conf_json['name'],
                           parent=conf_json['parent'])
     conf.exp_id = conf_json['exp_id']
     return conf