def __init__( self, penalty='L2', tol=1e-4, alpha=1.0, optimizer='rmsprop', batch_size=-1, shuffle=True, batch_strategy="full", masked_rate=5, 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'], floating_point_precision=23, encrypt_param=EncryptParam(), use_first_metric_only=False, stepwise_param=StepwiseParam(), callback_param=CallbackParam()): super(HeteroLogisticParam, self).__init__(penalty=penalty, tol=tol, alpha=alpha, optimizer=optimizer, batch_size=batch_size, shuffle=shuffle, batch_strategy=batch_strategy, masked_rate=masked_rate, 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, floating_point_precision=floating_point_precision, encrypt_param=encrypt_param, use_first_metric_only=use_first_metric_only, stepwise_param=stepwise_param, callback_param=callback_param) self.encrypted_mode_calculator_param = copy.deepcopy( encrypted_mode_calculator_param) self.sqn_param = copy.deepcopy(sqn_param)
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)
def __init__(self, penalty='L2', tol=1e-4, alpha=1.0, optimizer='rmsprop', batch_size=-1, shuffle=True, batch_strategy="full", masked_rate=5, 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', validation_freqs=None, early_stopping_rounds=None, stepwise_param=StepwiseParam(), floating_point_precision=23, metrics=None, use_first_metric_only=False, callback_param=CallbackParam()): super(LogisticParam, 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.shuffle = shuffle self.batch_strategy = batch_strategy self.masked_rate = masked_rate self.predict_param = copy.deepcopy(predict_param) self.cv_param = copy.deepcopy(cv_param) self.decay = decay self.decay_sqrt = decay_sqrt self.multi_class = multi_class self.validation_freqs = validation_freqs self.stepwise_param = copy.deepcopy(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)
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)
def __init__(self, penalty='L2', tol=1e-4, alpha=1.0, optimizer='rmsprop', batch_size=-1, learning_rate=0.01, init_param=InitParam(), max_iter=100, early_stop='diff', encrypt_param=EncryptParam(method=None), re_encrypt_batches=2, predict_param=PredictParam(), cv_param=CrossValidationParam(), decay=1, decay_sqrt=True, aggregate_iters=1, multi_class='ovr', validation_freqs=None, early_stopping_rounds=None, metrics=['auc', 'ks'], use_first_metric_only=False, use_proximal=False, mu=0.1, callback_param=CallbackParam()): super(HomoLogisticParam, 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, predict_param=predict_param, cv_param=cv_param, multi_class=multi_class, validation_freqs=validation_freqs, decay=decay, decay_sqrt=decay_sqrt, early_stopping_rounds=early_stopping_rounds, metrics=metrics, use_first_metric_only=use_first_metric_only, callback_param=callback_param) self.re_encrypt_batches = re_encrypt_batches self.aggregate_iters = aggregate_iters self.use_proximal = use_proximal self.mu = mu
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)
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)
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, n_iter_no_change=True, tol=0.0001, bin_num=32, predict_param=PredictParam(), cv_param=CrossValidationParam(), validation_freqs=None, use_missing=False, zero_as_missing=False, random_seed=100, binning_error=consts.DEFAULT_RELATIVE_ERROR, backend=consts.DISTRIBUTED_BACKEND, callback_param=CallbackParam(), multi_mode=consts.SINGLE_OUTPUT): super(HomoSecureBoostParam, self).__init__(task_type=task_type, objective_param=objective_param, learning_rate=learning_rate, num_trees=num_trees, subsample_feature_rate=subsample_feature_rate, n_iter_no_change=n_iter_no_change, tol=tol, bin_num=bin_num, predict_param=predict_param, cv_param=cv_param, validation_freqs=validation_freqs, random_seed=random_seed, binning_error=binning_error) self.use_missing = use_missing self.zero_as_missing = zero_as_missing self.tree_param = copy.deepcopy(tree_param) self.backend = backend self.callback_param = copy.deepcopy(callback_param) self.multi_mode = multi_mode
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
def __init__( self, secure_aggregate: bool = True, aggregate_every_n_epoch: int = 1, config_type: str = "nn", nn_define: dict = None, optimizer: typing.Union[str, dict, SimpleNamespace] = "SGD", loss: str = None, metrics: typing.Union[str, list] = None, max_iter: int = 100, batch_size: int = -1, early_stop: typing.Union[str, dict, SimpleNamespace] = "diff", encode_label: bool = False, predict_param=PredictParam(), cv_param=CrossValidationParam(), callback_param=CallbackParam(), ): super(HomoNNParam, self).__init__() self.secure_aggregate = secure_aggregate self.aggregate_every_n_epoch = aggregate_every_n_epoch self.config_type = config_type self.nn_define = nn_define or [] self.encode_label = encode_label self.batch_size = batch_size self.max_iter = max_iter self.early_stop = early_stop self.metrics = metrics self.optimizer = optimizer self.loss = loss self.predict_param = copy.deepcopy(predict_param) self.cv_param = copy.deepcopy(cv_param) self.callback_param = copy.deepcopy(callback_param)
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)
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
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, 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, tree_num_per_party=1, guest_depth=1, host_depth=1, work_mode='mix', metrics=None, sparse_optimization=False, random_seed=100, binning_error=consts.DEFAULT_RELATIVE_ERROR, cipher_compress_error=None, new_ver=True, run_goss=False, top_rate=0.2, other_rate=0.1, cipher_compress=True, callback_param=CallbackParam()): """ 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_rounds, use_missing, zero_as_missing, complete_secure, metrics=metrics, random_seed=random_seed, sparse_optimization=sparse_optimization, binning_error=binning_error, cipher_compress_error=cipher_compress_error, new_ver=new_ver, cipher_compress=cipher_compress, run_goss=run_goss, top_rate=top_rate, other_rate=other_rate) self.tree_num_per_party = tree_num_per_party self.guest_depth = guest_depth self.host_depth = host_depth self.work_mode = work_mode self.callback_param = copy.deepcopy(callback_param)