secretflow.ml.boost.sgb_v.core.pure_numpy_ops#

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.boost#

Functions:

compute_obj(G, H, reg_lambda)

compute objective values of input buckets.

compute_weight_from_node_select(node_select, ...)

compute_weight(G, H, reg_lambda, learning_rate)

compute weight values of tree leaf nodes.

find_best_splits(level_nodes_G, ...)

find the best split buckets and if gains > gamma

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.boost.compute_obj(G: ndarray, H: ndarray, reg_lambda: float) ndarray[源代码]#

compute objective values of input buckets.

参数:
  • G/H – sum of first and second order gradient in each bucket.

  • reg_lambda – L2 regularization term

返回:

objective values.

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.boost.compute_weight_from_node_select(node_select: ndarray, g: ndarray, h: ndarray, reg_lambda: float, learning_rate: float) ndarray[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.boost.compute_weight(G: float, H: float, reg_lambda: float, learning_rate: float) ndarray[源代码]#

compute weight values of tree leaf nodes.

参数:
  • G/H – sum of first and second order gradient in each node.

  • reg_lambda – L2 regularization term

  • learning_rate – Step size shrinkage used in update to prevents overfitting.

返回:

weight values.

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.boost.find_best_splits(level_nodes_G: List[array], level_nodes_H: List[array], reg_lambda: float, gamma: float) Tuple[ndarray, ndarray][源代码]#

find the best split buckets and if gains > gamma

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.bucket_sum#

Functions:

build_bin_indices_list(node_selects, ...)

batch_select_sum(arr, ...)

regroup_bucket_sums(bucket_sums_list, i)

cumsum_GH(x, bucket_num)

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.bucket_sum.build_bin_indices_list(node_selects, order_map, bucket_num)[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.bucket_sum.batch_select_sum(arr, children_nodes_selects, order_map, bucket_num)[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.bucket_sum.regroup_bucket_sums(bucket_sums_list, i)[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.bucket_sum.cumsum_GH(x, bucket_num)[源代码]#

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.grad#

Functions:

compute_gh_linear(y, pred)

compute_gh_logistic(y, pred)

split_GH(x)

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.grad.compute_gh_linear(y: ndarray, pred: ndarray)[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.grad.compute_gh_logistic(y: ndarray, pred: ndarray)[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.grad.split_GH(x) Tuple[ndarray, ndarray][源代码]#

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.node_select#

Functions:

root_select(samples)

get_child_select(nodes_s, lchilds_ss, ...)

compute the next level's sample select indices, and node indices

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.node_select.root_select(samples: int) List[ndarray][源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.node_select.get_child_select(nodes_s: List[ndarray], lchilds_ss: List[ndarray], gain_is_cost_effective: List[bool], split_node_indices: List[int]) Tuple[List[ndarray], List[int], List[ndarray], List[int]][源代码]#

compute the next level’s sample select indices, and node indices

参数:
  • nodes_s – sample select indices of each node from current level’s nodes.

  • lchilds_ss – left children’s sample selects idx for current level’s nodes (after pruning).

  • 1 (A non-empty single sample select is a np.ndarray with the shape n_samples *) –

  • node. (and with entries being 0 and 1s. 1 indicates the sample remains in) –

  • gain_is_cost_effective – List[bool]. indicate whether node should be split.

  • split_node_indices – List[int]. node indices at the current level.

返回:

sample select indices for nodes in the next level. node indices for the next level sample select indices for pruned nodes node indices for th pruned nodes

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.pred#

Functions:

init_pred(base, samples)

sigmoid(pred)

predict_tree_weight(selects, weights)

get final pred for this tree.

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.pred.init_pred(base: float, samples: int) ndarray[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.pred.sigmoid(pred: ndarray) ndarray[源代码]#
secretflow.ml.boost.sgb_v.core.pure_numpy_ops.pred.predict_tree_weight(selects: List[ndarray], weights: ndarray) ndarray[源代码]#

get final pred for this tree.

参数:
  • selects – leaf nodes’ sample selects from each model handler.

  • weights – leaf weights.

返回:

pred

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.random#

Functions:

create_permuation_with_last_number_fixed(size)

secretflow.ml.boost.sgb_v.core.pure_numpy_ops.random.create_permuation_with_last_number_fixed(size)[源代码]#