Exemple #1
0
 def from_json(obj, logger):
     projection_conf = None
     if obj['projection_conf'] is not None:
         proj_factory = ProjectionConfFactory.getFactory()
         projection_conf = proj_factory.from_json(obj['projection_conf'],
                                                 logger)
     return KmeansConf(logger, obj['num_clusters'],
                       projection_conf=projection_conf)
Exemple #2
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 = ProjectionConfFactory.getFactory()
     core_conf = factory.fromArgs(args.algo, args, secuml_conf.logger)
     return ProjectionConf(secuml_conf,
                           dataset_conf,
                           features_conf,
                           annotations_conf,
                           core_conf,
                           experiment_name=args.exp_name)
Exemple #3
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
Exemple #4
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)
     factory = ProjectionConfFactory.getFactory()
     core_conf = factory.from_json(conf_json['core_conf'],
                                   secuml_conf.logger)
     conf = ProjectionConf(secuml_conf,
                           dataset_conf,
                           features_conf,
                           annotations_conf,
                           core_conf,
                           experiment_name=conf_json['experiment_name'],
                           parent=conf_json['parent'])
     conf.experiment_id = conf_json['experiment_id']
     return conf
Exemple #5
0
from SecuML.core.projection.algos.Lda import Lda
from SecuML.core.projection.conf import ProjectionConfFactory

from .SemiSupervisedProjectionConf import SemiSupervisedProjectionConf


class LdaConf(SemiSupervisedProjectionConf):
    def __init__(self, logger, num_components=None, families_supervision=None):
        SemiSupervisedProjectionConf.__init__(
            self,
            logger,
            Lda,
            num_components=num_components,
            families_supervision=families_supervision)

    @staticmethod
    def fromArgs(args, logger):
        return LdaConf(logger,
                       num_components=args.num_components,
                       families_supervision=args.families_supervision)

    @staticmethod
    def from_json(obj, logger):
        return LdaConf(logger,
                       num_components=obj['num_components'],
                       families_supervision=obj['families_supervision'])


ProjectionConfFactory.getFactory().registerClass('LdaConf', LdaConf)
Exemple #6
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with SecuML. If not, see <http://www.gnu.org/licenses/>.

from SecuML.core.projection.algos.Itml import Itml
from SecuML.core.projection.conf import ProjectionConfFactory

from .SemiSupervisedProjectionConf import SemiSupervisedProjectionConf


class ItmlConf(SemiSupervisedProjectionConf):
    def __init__(self, logger, families_supervision=None):
        SemiSupervisedProjectionConf.__init__(
            self, logger, Itml, families_supervision=families_supervision)

    @staticmethod
    def from_json(obj, logger):
        conf = ItmlConf(logger,
                        families_supervision=obj['families_supervision'])
        conf.num_components = obj['num_components']
        return conf

    @staticmethod
    def fromArgs(args, logger):
        return ItmlConf(logger, args.families_supervision)


ProjectionConfFactory.getFactory().registerClass('ItmlConf', ItmlConf)
Exemple #7
0
 def proj_conf_from_args(args, logger):
     if not hasattr(args, 'projection_algo') or args.projection_algo is None:
         return None
     proj_factory = ProjectionConfFactory.getFactory()
     proj_conf = proj_factory.fromArgs(args.projection_algo, args, logger)
     return proj_conf