Exemplo n.º 1
0
 def setExperimentFromArgs(self, args):
     self.setFeaturesFilenames(args.features_files)
     factory = DimensionReductionConfFactory.getFactory()
     conf = factory.fromArgs(args.algo, args)
     self.setConf(conf)
     self.initLabels(args.labels_file)
     self.export()
Exemplo n.º 2
0
 def fromJson(obj):
     conf = KmeansConfiguration(obj['num_clusters'])
     if obj['projection_conf'] is not None:
         projection_conf = DimensionReductionConfFactory.getFactory(
         ).fromJson(obj['projection_conf'])
         conf.setDimensionReductionConf(projection_conf)
     return conf
Exemplo n.º 3
0
 def fromJson(obj, session):
     conf = DimensionReductionConfFactory.getFactory().fromJson(obj['conf'])
     experiment = FeatureSelectionExperiment(obj['project'], obj['dataset'],
                                             session)
     DimensionReductionExperiment.expParamFromJson(experiment, obj)
     experiment.setConf(conf)
     return experiment
Exemplo n.º 4
0
 def fromJson(obj):
     conf = ClusteringConfiguration(obj['num_clusters'],
                                    num_results=obj['num_results'],
                                    label=obj['label'])
     if obj['projection_conf'] is not None:
         projection_conf = DimensionReductionConfFactory.getFactory(
         ).fromJson(obj['projection_conf'])
         conf.setDimensionReductionConf(projection_conf)
     return conf
 def fromJson(obj):
     conf = GaussianMixtureConfiguration(obj['num_clusters'])
     conf.covariance_type = obj['covariance_type']
     conf.init_params = obj['init_params']
     conf.max_iter = obj['max_iter']
     if obj['projection_conf'] is not None:
         projection_conf = DimensionReductionConfFactory.getFactory().fromJson(obj['projection_conf'])
         conf.setDimensionReductionConf(projection_conf)
     return conf
Exemplo n.º 6
0
 def generateParser():
     parser = argparse.ArgumentParser(
         description='Projection of the data for data visualization.')
     DimensionReductionExperiment.projectDatasetFeturesParser(parser)
     DimensionReductionExperiment.generateDimensionReductionParser(parser)
     algos = ['Pca', 'Rca', 'Lda', 'Lmnn', 'Nca', 'Itml']
     subparsers = parser.add_subparsers(dest='algo')
     factory = DimensionReductionConfFactory.getFactory()
     for algo in algos:
         algo_parser = subparsers.add_parser(algo)
         factory.generateParser(algo, algo_parser)
     return parser
Exemplo n.º 7
0
 def generateParser():
     parser = argparse.ArgumentParser(description='Feature Selection.')
     algos = [
         'ChiSquare', 'Fclassif', 'MutualInfoClassif', 'VarianceFilter',
         'RecursiveFeatureElimination', 'NoneFilter'
     ]
     DimensionReductionExperiment.projectDatasetFeturesParser(parser)
     DimensionReductionExperiment.generateDimensionReductionParser(parser)
     subparsers = parser.add_subparsers(dest='algo')
     factory = DimensionReductionConfFactory.getFactory()
     for algo in algos:
         algo_parser = subparsers.add_parser(algo)
         factory.generateParser(algo, algo_parser)
     return parser
Exemplo n.º 8
0
    def generateParamsFromArgs(args):

        # DimensionReduction parameters
        projection_conf = None
        if args.projection_algo is not None:
            projection_args = {}
            projection_args['families_supervision'] = args.families_supervision
            projection_args['num_components'] = None
            projection_conf = DimensionReductionConfFactory.getFactory(
            ).fromParam(args.projection_algo, projection_args)

        # Clustering parameters
        params = {}
        params['num_clusters'] = args.num_clusters
        params['num_results'] = 5
        params['projection_conf'] = projection_conf
        params['label'] = args.label

        return params
Exemplo n.º 9
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.DimensionReduction.Algorithms.FeatureSelection.VarianceFilter import VarianceFilter
from SecuML.DimensionReduction.Configuration import DimensionReductionConfFactory

from UnsupervisedFeatureSelectionConfiguration import UnsupervisedFeatureSelectionConfiguration


class VarianceFilterConfiguration(UnsupervisedFeatureSelectionConfiguration):
    def __init__(self):
        UnsupervisedFeatureSelectionConfiguration.__init__(
            self, VarianceFilter)

    @staticmethod
    def fromJson(obj):
        conf = VarianceFilterConfiguration()
        return conf

    def toJson(self):
        conf = UnsupervisedFeatureSelectionConfiguration.toJson(self)
        conf['__type__'] = 'VarianceFilterConfiguration'
        return conf


DimensionReductionConfFactory.getFactory().registerClass(
    'VarianceFilterConfiguration', VarianceFilterConfiguration)
Exemplo n.º 10
0
##
## 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.DimensionReduction.Algorithms.Projection.Lmnn import Lmnn
from SecuML.DimensionReduction.Configuration import DimensionReductionConfFactory

from SemiSupervisedProjectionConfiguration import SemiSupervisedProjectionConfiguration


class LmnnConfiguration(SemiSupervisedProjectionConfiguration):
    def __init__(self, families_supervision=None):
        SemiSupervisedProjectionConfiguration.__init__(
            self, Lmnn, families_supervision=families_supervision)

    @staticmethod
    def fromJson(obj):
        conf = LmnnConfiguration(
            families_supervision=obj['families_supervision'])
        conf.num_components = obj['num_components']
        return conf

    def toJson(self):
        conf = SemiSupervisedProjectionConfiguration.toJson(self)
        conf['__type__'] = 'LmnnConfiguration'
        return conf


DimensionReductionConfFactory.getFactory().registerClass(
    'LmnnConfiguration', LmnnConfiguration)
Exemplo n.º 11
0
## 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.DimensionReduction.Algorithms.FeatureSelection.MutualInfoClassif import MutualInfoClassif
from SecuML.DimensionReduction.Configuration import DimensionReductionConfFactory

from SemiSupervisedFeatureSelectionConfiguration import SemiSupervisedFeatureSelectionConfiguration

class MutualInfoClassifConfiguration(SemiSupervisedFeatureSelectionConfiguration):

    def __init__(self, num_components = None, families_supervision = None):
        SemiSupervisedFeatureSelectionConfiguration.__init__(self, MutualInfoClassif,
                num_components = num_components,
                families_supervision = families_supervision)

    @staticmethod
    def fromJson(obj):
        conf = MutualInfoClassifConfiguration(num_components = obj['num_components'],
                families_supervision = obj['families_supervision'])
        return conf

    def toJson(self):
        conf = SemiSupervisedFeatureSelectionConfiguration.toJson(self)
        conf['__type__'] = 'MutualInfoClassifConfiguration'
        return conf

DimensionReductionConfFactory.getFactory().registerClass('MutualInfoClassifConfiguration',
                                                         MutualInfoClassifConfiguration)
        params = SemiSupervisedFeatureSelectionConfiguration.generateParamsFromArgs(
            args)
        params['step'] = args.step
        if args.model == 'LogisticRegression':
            model = LogisticRegression()
        elif args.model == 'Svc':
            model = SVC(kernel='linear')
        elif args.model == 'DecisionTree':
            model = DecisionTreeClassifier()
        elif args.model == 'RandomForest':
            model = RandomForestClassifier()
        params['model'] = model
        return params

    @staticmethod
    def generateParser(parser):
        SemiSupervisedFeatureSelectionConfiguration.generateParser(parser)
        parser.add_argument('--step', type=int, default=1)
        parser.add_argument('--model',
                            type=str,
                            choices=[
                                'LogisticRegression', 'Svc', 'DecisionTree',
                                'RandomForest'
                            ],
                            default='LogisticRegression')


DimensionReductionConfFactory.getFactory().registerClass(
    'RecursiveFeatureEliminationConfiguration',
    RecursiveFeatureEliminationConfiguration)
Exemplo n.º 13
0
from SecuML.DimensionReduction.Algorithms.FeatureSelection.Fclassif import Fclassif
from SecuML.DimensionReduction.Configuration import DimensionReductionConfFactory

from SemiSupervisedFeatureSelectionConfiguration import SemiSupervisedFeatureSelectionConfiguration


class FclassifConfiguration(SemiSupervisedFeatureSelectionConfiguration):
    def __init__(self, num_components=None, families_supervision=None):
        SemiSupervisedFeatureSelectionConfiguration.__init__(
            self,
            Fclassif,
            num_components=num_components,
            families_supervision=families_supervision)

    @staticmethod
    def fromJson(obj):
        conf = FclassifConfiguration(
            num_components=obj['num_components'],
            families_supervision=obj['families_supervision'])
        return conf

    def toJson(self):
        conf = SemiSupervisedFeatureSelectionConfiguration.toJson(self)
        conf['__type__'] = 'FclassifConfiguration'
        return conf


DimensionReductionConfFactory.getFactory().registerClass(
    'FclassifConfiguration', FclassifConfiguration)
Exemplo n.º 14
0
## 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.DimensionReduction.Algorithms.FeatureSelection.ChiSquare import ChiSquare
from SecuML.DimensionReduction.Configuration import DimensionReductionConfFactory

from SemiSupervisedFeatureSelectionConfiguration import SemiSupervisedFeatureSelectionConfiguration

class ChiSquareConfiguration(SemiSupervisedFeatureSelectionConfiguration):

    def __init__(self, num_components = None, families_supervision = None):
        SemiSupervisedFeatureSelectionConfiguration.__init__(self, ChiSquare,
                num_components = num_components,
                families_supervision = families_supervision)

    @staticmethod
    def fromJson(obj):
        conf = ChiSquareConfiguration(num_components = obj['num_components'],
                families_supervision = obj['families_supervision'])
        return conf

    def toJson(self):
        conf = SemiSupervisedFeatureSelectionConfiguration.toJson(self)
        conf['__type__'] = 'ChiSquareConfiguration'
        return conf

DimensionReductionConfFactory.getFactory().registerClass('ChiSquareConfiguration',
                                                         ChiSquareConfiguration)
Exemplo n.º 15
0
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## 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.DimensionReduction.Algorithms.FeatureSelection.NoneFilter import NoneFilter
from SecuML.DimensionReduction.Configuration import DimensionReductionConfFactory

from UnsupervisedFeatureSelectionConfiguration import UnsupervisedFeatureSelectionConfiguration


class NoneFilterConfiguration(UnsupervisedFeatureSelectionConfiguration):
    def __init__(self):
        UnsupervisedFeatureSelectionConfiguration.__init__(self, NoneFilter)

    @staticmethod
    def fromJson(obj):
        conf = NoneFilterConfiguration()
        return conf

    def toJson(self):
        conf = UnsupervisedFeatureSelectionConfiguration.toJson(self)
        conf['__type__'] = 'NoneFilterConfiguration'
        return conf


DimensionReductionConfFactory.getFactory().registerClass(
    'NoneFilterConfiguration', NoneFilterConfiguration)