コード例 #1
0
ファイル: boosting_param.py プロジェクト: zpskt/FATE
    def __init__(self, tree_param: DecisionTreeParam = DecisionTreeParam(), task_type=consts.CLASSIFICATION,
                 objective_param=ObjectiveParam(),
                 learning_rate=0.3, num_trees=5, subsample_feature_rate=1.0, n_iter_no_change=True,
                 tol=0.0001, encrypt_param=EncryptParam(),
                 bin_num=32,
                 encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
                 predict_param=PredictParam(), cv_param=CrossValidationParam(),
                 validation_freqs=None, early_stopping_rounds=None, use_missing=False, zero_as_missing=False,
                 complete_secure=False, metrics=None, use_first_metric_only=False, subsample_random_seed=None,
                 binning_error=consts.DEFAULT_RELATIVE_ERROR,
                 sparse_optimization=False):

        super(HeteroSecureBoostParam, self).__init__(task_type, objective_param, learning_rate, num_trees,
                                                     subsample_feature_rate, n_iter_no_change, tol, encrypt_param,
                                                     bin_num, encrypted_mode_calculator_param, predict_param, cv_param,
                                                     validation_freqs, early_stopping_rounds, metrics=metrics,
                                                     use_first_metric_only=use_first_metric_only,
                                                     subsample_random_seed=subsample_random_seed,
                                                     binning_error=binning_error)

        self.tree_param = tree_param
        self.zero_as_missing = zero_as_missing
        self.use_missing = use_missing
        self.complete_secure = complete_secure
        self.sparse_optimization = sparse_optimization
コード例 #2
0
ファイル: linear_regression_param.py プロジェクト: zpskt/FATE
 def __init__(self, penalty='L2',
              tol=1e-5, alpha=1.0, optimizer='sgd',
              batch_size=-1, learning_rate=0.01, init_param=InitParam(),
              max_iter=100, early_stop='diff', predict_param=PredictParam(),
              encrypt_param=EncryptParam(), sqn_param=StochasticQuasiNewtonParam(),
              encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
              cv_param=CrossValidationParam(), decay=1, decay_sqrt=True, validation_freqs=None,
              early_stopping_rounds=None, stepwise_param=StepwiseParam(), metrics=None, use_first_metric_only=False):
     super(LinearParam, self).__init__()
     self.penalty = penalty
     self.tol = tol
     self.alpha = alpha
     self.optimizer = optimizer
     self.batch_size = batch_size
     self.learning_rate = learning_rate
     self.init_param = copy.deepcopy(init_param)
     self.max_iter = max_iter
     self.early_stop = early_stop
     self.encrypt_param = encrypt_param
     self.encrypted_mode_calculator_param = copy.deepcopy(encrypted_mode_calculator_param)
     self.cv_param = copy.deepcopy(cv_param)
     self.predict_param = copy.deepcopy(predict_param)
     self.decay = decay
     self.decay_sqrt = decay_sqrt
     self.validation_freqs = validation_freqs
     self.sqn_param = copy.deepcopy(sqn_param)
     self.early_stopping_rounds = early_stopping_rounds
     self.stepwise_param = copy.deepcopy(stepwise_param)
     self.metrics = metrics or []
     self.use_first_metric_only = use_first_metric_only
コード例 #3
0
 def __init__(self, penalty='L2',
              tol=1e-5, alpha=1.0, optimizer='sgd',
              batch_size=-1, learning_rate=0.01, init_param=InitParam(),
              max_iter=100, early_stop='diff',
              encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
              predict_param=PredictParam(), cv_param=CrossValidationParam(),
              decay=1, decay_sqrt=True, sqn_param=StochasticQuasiNewtonParam(),
              multi_class='ovr', validation_freqs=None, early_stopping_rounds=None,
              metrics=['auc', 'ks'],
              use_first_metric_only=False, stepwise_param=StepwiseParam()
              ):
     super(HeteroLogisticParam, self).__init__(penalty=penalty, tol=tol, alpha=alpha, optimizer=optimizer,
                                               batch_size=batch_size,
                                               learning_rate=learning_rate,
                                               init_param=init_param, max_iter=max_iter, early_stop=early_stop,
                                               predict_param=predict_param, cv_param=cv_param,
                                               decay=decay,
                                               decay_sqrt=decay_sqrt, multi_class=multi_class,
                                               validation_freqs=validation_freqs,
                                               early_stopping_rounds=early_stopping_rounds,
                                               metrics=metrics,
                                               use_first_metric_only=use_first_metric_only,
                                               stepwise_param=stepwise_param)
     self.encrypted_mode_calculator_param = copy.deepcopy(encrypted_mode_calculator_param)
     self.sqn_param = copy.deepcopy(sqn_param)
コード例 #4
0
    def __init__(self,
                 task_type='classification',
                 config_type="keras",
                 bottom_nn_define=None,
                 top_nn_define=None,
                 interactive_layer_define=None,
                 interactive_layer_lr=0.9,
                 optimizer='SGD',
                 loss=None,
                 epochs=100,
                 batch_size=-1,
                 early_stop="diff",
                 tol=1e-5,
                 encrypt_param=EncryptParam(),
                 encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
                 predict_param=PredictParam(),
                 cv_param=CrossValidationParam(),
                 validation_freqs=None,
                 early_stopping_rounds=None,
                 metrics=None,
                 use_first_metric_only=True,
                 selector_param=SelectorParam(),
                 floating_point_precision=23,
                 drop_out_keep_rate=1.0,
                 callback_param=CallbackParam()):
        super(HeteroNNParam, self).__init__()

        self.task_type = task_type
        self.config_type = config_type
        self.bottom_nn_define = bottom_nn_define
        self.interactive_layer_define = interactive_layer_define
        self.interactive_layer_lr = interactive_layer_lr
        self.top_nn_define = top_nn_define
        self.batch_size = batch_size
        self.epochs = epochs
        self.early_stop = early_stop
        self.tol = tol
        self.optimizer = optimizer
        self.loss = loss
        self.validation_freqs = validation_freqs
        self.early_stopping_rounds = early_stopping_rounds
        self.metrics = metrics or []
        self.use_first_metric_only = use_first_metric_only

        self.encrypt_param = copy.deepcopy(encrypt_param)
        self.encrypted_model_calculator_param = encrypted_mode_calculator_param
        self.predict_param = copy.deepcopy(predict_param)
        self.cv_param = copy.deepcopy(cv_param)

        self.selector_param = selector_param
        self.floating_point_precision = floating_point_precision

        self.drop_out_keep_rate = drop_out_keep_rate

        self.callback_param = copy.deepcopy(callback_param)
コード例 #5
0
    def __init__(
        self,
        penalty='L2',
        tol=1e-5,
        alpha=1.0,
        optimizer='sgd',
        batch_size=-1,
        learning_rate=0.01,
        init_param=InitParam(),
        max_iter=100,
        early_stop='diff',
        exposure_colname=None,
        predict_param=PredictParam(),
        encrypt_param=EncryptParam(),
        encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
        cv_param=CrossValidationParam(),
        stepwise_param=StepwiseParam(),
        decay=1,
        decay_sqrt=True,
        validation_freqs=None,
        early_stopping_rounds=None,
        metrics=None,
        use_first_metric_only=False,
        floating_point_precision=23,
        callback_param=CallbackParam()):
        super(PoissonParam, self).__init__()
        self.penalty = penalty
        self.tol = tol
        self.alpha = alpha
        self.optimizer = optimizer
        self.batch_size = batch_size
        self.learning_rate = learning_rate
        self.init_param = copy.deepcopy(init_param)

        self.max_iter = max_iter
        self.early_stop = early_stop
        self.encrypt_param = encrypt_param
        self.encrypted_mode_calculator_param = copy.deepcopy(
            encrypted_mode_calculator_param)
        self.cv_param = copy.deepcopy(cv_param)
        self.predict_param = copy.deepcopy(predict_param)
        self.decay = decay
        self.decay_sqrt = decay_sqrt
        self.exposure_colname = exposure_colname
        self.validation_freqs = validation_freqs
        self.stepwise_param = stepwise_param
        self.early_stopping_rounds = early_stopping_rounds
        self.metrics = metrics or []
        self.use_first_metric_only = use_first_metric_only
        self.floating_point_precision = floating_point_precision
        self.callback_param = copy.deepcopy(callback_param)
コード例 #6
0
 def __init__(
     self,
     penalty='L2',
     tol=1e-4,
     alpha=1.0,
     optimizer='sgd',
     batch_size=-1,
     learning_rate=0.01,
     init_param=InitParam(),
     max_iter=20,
     early_stop='diff',
     encrypt_param=EncryptParam(),
     sqn_param=StochasticQuasiNewtonParam(),
     encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
     cv_param=CrossValidationParam(),
     decay=1,
     decay_sqrt=True,
     validation_freqs=None,
     early_stopping_rounds=None,
     stepwise_param=StepwiseParam(),
     metrics=None,
     use_first_metric_only=False,
     floating_point_precision=23,
     callback_param=CallbackParam()):
     super(LinearParam,
           self).__init__(penalty=penalty,
                          tol=tol,
                          alpha=alpha,
                          optimizer=optimizer,
                          batch_size=batch_size,
                          learning_rate=learning_rate,
                          init_param=init_param,
                          max_iter=max_iter,
                          early_stop=early_stop,
                          encrypt_param=encrypt_param,
                          cv_param=cv_param,
                          decay=decay,
                          decay_sqrt=decay_sqrt,
                          validation_freqs=validation_freqs,
                          early_stopping_rounds=early_stopping_rounds,
                          stepwise_param=stepwise_param,
                          metrics=metrics,
                          use_first_metric_only=use_first_metric_only,
                          floating_point_precision=floating_point_precision,
                          callback_param=callback_param)
     self.sqn_param = copy.deepcopy(sqn_param)
     self.encrypted_mode_calculator_param = copy.deepcopy(
         encrypted_mode_calculator_param)
コード例 #7
0
 def __init__(
     self,
     penalty=None,
     tol=1e-4,
     alpha=1.0,
     optimizer='sgd',
     batch_size=-1,
     learning_rate=0.01,
     init_param=InitParam(),
     max_iter=100,
     early_stop='diff',
     encrypt_param=EncryptParam(),
     predict_param=PredictParam(),
     cv_param=CrossValidationParam(),
     decay=1,
     decay_sqrt=True,
     multi_class='ovr',
     use_mix_rand=True,
     reveal_strategy="respectively",
     reveal_every_iter=True,
     callback_param=CallbackParam(),
     encrypted_mode_calculator_param=EncryptedModeCalculatorParam()):
     super(LogisticRegressionParam, self).__init__()
     self.penalty = penalty
     self.tol = tol
     self.alpha = alpha
     self.optimizer = optimizer
     self.batch_size = batch_size
     self.learning_rate = learning_rate
     self.init_param = copy.deepcopy(init_param)
     self.max_iter = max_iter
     self.early_stop = early_stop
     self.encrypt_param = encrypt_param
     self.predict_param = copy.deepcopy(predict_param)
     self.decay = decay
     self.decay_sqrt = decay_sqrt
     self.multi_class = multi_class
     self.use_mix_rand = use_mix_rand
     self.reveal_strategy = reveal_strategy
     self.reveal_every_iter = reveal_every_iter
     self.callback_param = copy.deepcopy(callback_param)
     self.cv_param = cv_param
     self.encrypted_mode_calculator_param = copy.deepcopy(
         encrypted_mode_calculator_param)
コード例 #8
0
ファイル: boosting_param.py プロジェクト: zeta1999/FATE
    def __init__(
            self,
            task_type=consts.CLASSIFICATION,
            objective_param=ObjectiveParam(),
            learning_rate=0.3,
            num_trees=5,
            subsample_feature_rate=1,
            n_iter_no_change=True,
            tol=0.0001,
            encrypt_param=EncryptParam(),
            bin_num=32,
            encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
            predict_param=PredictParam(),
            cv_param=CrossValidationParam(),
            validation_freqs=None,
            early_stopping_rounds=None,
            metrics=None,
            use_first_metric_only=False,
            subsample_random_seed=None,
            binning_error=consts.DEFAULT_RELATIVE_ERROR):

        super(HeteroBoostingParam,
              self).__init__(task_type,
                             objective_param,
                             learning_rate,
                             num_trees,
                             subsample_feature_rate,
                             n_iter_no_change,
                             tol,
                             bin_num,
                             predict_param,
                             cv_param,
                             validation_freqs,
                             metrics=metrics,
                             subsample_random_seed=subsample_random_seed,
                             binning_error=binning_error)

        self.encrypt_param = copy.deepcopy(encrypt_param)
        self.encrypted_mode_calculator_param = copy.deepcopy(
            encrypted_mode_calculator_param)
        self.early_stopping_rounds = early_stopping_rounds
        self.use_first_metric_only = use_first_metric_only
コード例 #9
0
 def __init__(
         self,
         penalty='L2',
         tol=1e-4,
         alpha=1.0,
         optimizer='sgd',
         batch_size=-1,
         learning_rate=0.01,
         init_param=InitParam(),
         max_iter=20,
         early_stop='diff',
         encrypt_param=EncryptParam(),
         encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
         cv_param=CrossValidationParam(),
         decay=1,
         decay_sqrt=True,
         callback_param=CallbackParam(),
         use_mix_rand=True,
         reveal_strategy="respectively",
         reveal_every_iter=False):
     super(HeteroSSHELinRParam,
           self).__init__(penalty=penalty,
                          tol=tol,
                          alpha=alpha,
                          optimizer=optimizer,
                          batch_size=batch_size,
                          learning_rate=learning_rate,
                          init_param=init_param,
                          max_iter=max_iter,
                          early_stop=early_stop,
                          encrypt_param=encrypt_param,
                          cv_param=cv_param,
                          decay=decay,
                          decay_sqrt=decay_sqrt,
                          callback_param=callback_param)
     self.encrypted_mode_calculator_param = copy.deepcopy(
         encrypted_mode_calculator_param)
     self.use_mix_rand = use_mix_rand
     self.reveal_strategy = reveal_strategy
     self.reveal_every_iter = reveal_every_iter
コード例 #10
0
ファイル: boosting_param.py プロジェクト: zpskt/FATE
    def __init__(self, tree_param: DecisionTreeParam = DecisionTreeParam(), task_type=consts.CLASSIFICATION,
                 objective_param=ObjectiveParam(),
                 learning_rate=0.3, num_trees=5, subsample_feature_rate=1.0, n_iter_no_change=True,
                 tol=0.0001, encrypt_param=EncryptParam(),
                 bin_num=32,
                 encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
                 predict_param=PredictParam(), cv_param=CrossValidationParam(),
                 validation_freqs=None, early_stopping=None, use_missing=False, zero_as_missing=False,
                 complete_secure=False, tree_num_per_party=1, guest_depth=1, host_depth=1, work_mode='mix', metrics=None,
                 subsample_random_seed=None, binning_error=consts.DEFAULT_RELATIVE_ERROR, sparse_optimization=False):

        """
        work_mode:
            mix:  alternate using guest/host features to build trees. For example, the first 'tree_num_per_party' trees use guest features,
                  the second k trees use host features, and so on
            layered: only support 2 party, when running layered mode, first 'host_depth' layer will use host features,
                     and then next 'guest_depth' will only use guest features
        tree_num_per_party: every party will alternate build 'tree_num_per_party' trees until reach max tree num, this param is valid when work_mode is
            mix
        guest_depth: guest will build last guest_depth of a decision tree using guest features, is valid when work mode
            is layered
        host depth: host will build first host_depth of a decision tree using host features, is valid when work mode is
            layered

        other params are the same as HeteroSecureBoost
        """

        super(HeteroFastSecureBoostParam, self).__init__(tree_param, task_type, objective_param, learning_rate,
                                                         num_trees, subsample_feature_rate, n_iter_no_change, tol,
                                                         encrypt_param, bin_num, encrypted_mode_calculator_param,
                                                         predict_param, cv_param, validation_freqs, early_stopping,
                                                         use_missing, zero_as_missing, complete_secure, metrics=metrics,
                                                         subsample_random_seed=subsample_random_seed,
                                                         binning_error=binning_error, sparse_optimization=sparse_optimization)

        self.tree_num_per_party = tree_num_per_party
        self.guest_depth = guest_depth
        self.host_depth = host_depth
        self.work_mode = work_mode
コード例 #11
0
ファイル: ftl_param.py プロジェクト: FederatedAI/FATE
    def __init__(self,
                 alpha=1,
                 tol=0.000001,
                 n_iter_no_change=False,
                 validation_freqs=None,
                 optimizer={
                     'optimizer': 'Adam',
                     'learning_rate': 0.01
                 },
                 nn_define={},
                 epochs=1,
                 intersect_param=IntersectParam(consts.RSA),
                 config_type='keras',
                 batch_size=-1,
                 encrypte_param=EncryptParam(),
                 encrypted_mode_calculator_param=EncryptedModeCalculatorParam(
                     mode="confusion_opt"),
                 predict_param=PredictParam(),
                 mode='plain',
                 communication_efficient=False,
                 local_round=5,
                 callback_param=CallbackParam()):
        """
        Args:
            alpha: float, a loss coefficient defined in paper, it defines the importance of alignment loss
            tol:  float, loss tolerance
            n_iter_no_change: bool, check loss convergence or not
            validation_freqs: None or positive integer or container object in python. Do validation in training process or Not.
                if equals None, will not do validation in train process;
                if equals positive integer, will validate data every validation_freqs epochs passes;
                if container object in python, will validate data if epochs belong to this container.
                e.g. validation_freqs = [10, 15], will validate data when epoch equals to 10 and 15.
                Default: None
                The default value is None, 1 is suggested. You can set it to a number larger than 1 in order to
                speed up training by skipping validation rounds. When it is larger than 1, a number which is
                divisible by "epochs" is recommended, otherwise, you will miss the validation scores
                of last training epoch.
            optimizer: optimizer method, accept following types:
                1. a string, one of "Adadelta", "Adagrad", "Adam", "Adamax", "Nadam", "RMSprop", "SGD"
                2. a dict, with a required key-value pair keyed by "optimizer",
                    with optional key-value pairs such as learning rate.
                defaults to "SGD"
            nn_define:  dict, a dict represents the structure of neural network, it can be output by tf-keras
            epochs: int, epochs num
            intersect_param: define the intersect method
            config_type: now only 'tf-keras' is supported
            batch_size: batch size when computing transformed feature embedding, -1 use full data.
            encrypte_param: encrypted param
            encrypted_mode_calculator_param:
            predict_param: predict param
            mode:
                plain: will not use any encrypt algorithms, data exchanged in plaintext
                encrypted: use paillier to encrypt gradients
            communication_efficient:
                bool, will use communication efficient or not. when communication efficient is enabled, FTL model will
                update gradients by several local rounds using intermediate data
            local_round: local update round when using communication efficient
        """

        super(FTLParam, self).__init__()
        self.alpha = alpha
        self.tol = tol
        self.n_iter_no_change = n_iter_no_change
        self.validation_freqs = validation_freqs
        self.optimizer = optimizer
        self.nn_define = nn_define
        self.epochs = epochs
        self.intersect_param = copy.deepcopy(intersect_param)
        self.config_type = config_type
        self.batch_size = batch_size
        self.encrypted_mode_calculator_param = copy.deepcopy(
            encrypted_mode_calculator_param)
        self.encrypt_param = copy.deepcopy(encrypte_param)
        self.predict_param = copy.deepcopy(predict_param)
        self.mode = mode
        self.communication_efficient = communication_efficient
        self.local_round = local_round
        self.callback_param = copy.deepcopy(callback_param)
コード例 #12
0
ファイル: boosting_param.py プロジェクト: yubo1993/FATE
    def __init__(
            self,
            tree_param: DecisionTreeParam = DecisionTreeParam(),
            task_type=consts.CLASSIFICATION,
            objective_param=ObjectiveParam(),
            learning_rate=0.3,
            num_trees=5,
            subsample_feature_rate=1.0,
            n_iter_no_change=True,
            tol=0.0001,
            encrypt_param=EncryptParam(),
            bin_num=32,
            encrypted_mode_calculator_param=EncryptedModeCalculatorParam(),
            predict_param=PredictParam(),
            cv_param=CrossValidationParam(),
            validation_freqs=None,
            early_stopping_rounds=None,
            use_missing=False,
            zero_as_missing=False,
            complete_secure=False,
            metrics=None,
            use_first_metric_only=False,
            random_seed=100,
            binning_error=consts.DEFAULT_RELATIVE_ERROR,
            sparse_optimization=False,
            run_goss=False,
            top_rate=0.2,
            other_rate=0.1,
            cipher_compress_error=None,
            cipher_compress=True,
            new_ver=True,
            boosting_strategy=consts.STD_TREE,
            work_mode=None,
            tree_num_per_party=1,
            guest_depth=2,
            host_depth=3,
            callback_param=CallbackParam(),
            multi_mode=consts.SINGLE_OUTPUT,
            EINI_inference=False,
            EINI_random_mask=False,
            EINI_complexity_check=False):

        super(HeteroSecureBoostParam,
              self).__init__(task_type,
                             objective_param,
                             learning_rate,
                             num_trees,
                             subsample_feature_rate,
                             n_iter_no_change,
                             tol,
                             encrypt_param,
                             bin_num,
                             encrypted_mode_calculator_param,
                             predict_param,
                             cv_param,
                             validation_freqs,
                             early_stopping_rounds,
                             metrics=metrics,
                             use_first_metric_only=use_first_metric_only,
                             random_seed=random_seed,
                             binning_error=binning_error)

        self.tree_param = copy.deepcopy(tree_param)
        self.zero_as_missing = zero_as_missing
        self.use_missing = use_missing
        self.complete_secure = complete_secure
        self.sparse_optimization = sparse_optimization
        self.run_goss = run_goss
        self.top_rate = top_rate
        self.other_rate = other_rate
        self.cipher_compress_error = cipher_compress_error
        self.cipher_compress = cipher_compress
        self.new_ver = new_ver
        self.EINI_inference = EINI_inference
        self.EINI_random_mask = EINI_random_mask
        self.EINI_complexity_check = EINI_complexity_check
        self.boosting_strategy = boosting_strategy
        self.work_mode = work_mode
        self.tree_num_per_party = tree_num_per_party
        self.guest_depth = guest_depth
        self.host_depth = host_depth
        self.callback_param = copy.deepcopy(callback_param)
        self.multi_mode = multi_mode