secretflow.ml.boost.sgb_v.core.distributed_tree#

secretflow.ml.boost.sgb_v.core.distributed_tree.distributed_tree#

Classes:

DistributedTree()

A DistributedTree consists of split trees from each party and leaf weight from label holder

Functions:

from_dict(tree_content)

class secretflow.ml.boost.sgb_v.core.distributed_tree.distributed_tree.DistributedTree[source]#

Bases: object

A DistributedTree consists of split trees from each party and leaf weight from label holder

Methods:

__init__()

insert_split_tree(device, split_tree)

insert a split tree owned by deivce

set_leaf_weight(label_holder, leaf_weight)

leaf weight is owned by label holder

predict(x)

predict using a single tree.

to_dict()

Serialize to a Dictionary.

__init__()[source]#
insert_split_tree(device: PYU, split_tree: PYUObject)[source]#

insert a split tree owned by deivce

Parameters:
  • device (PYU) – split tree owner

  • split_tree (PYUObject) – split tree in disguise

set_leaf_weight(label_holder: PYU, leaf_weight: PYUObject)[source]#

leaf weight is owned by label holder

predict(x: Dict[PYU, PYUObject]) PYUObject[source]#

predict using a single tree. A single tree is actually consists of all split trees. Note the model predict = base + sum of tree predict. This is useful in both training and inference

Parameters:
  • tree (Dict[PYU, PYUObject]) – {party: split tree}

  • weight (PYUObject) – leaf weights from label holder

  • x (Dict[PYU, PYUObject]) – partitions of FedNdarray. {party: party’s partition}

Returns:

_description_

Return type:

PYUObject

to_dict() Dict[source]#

Serialize to a Dictionary. Note this dict contain PYUObjects, cannot dump to file at this level.

secretflow.ml.boost.sgb_v.core.distributed_tree.distributed_tree.from_dict(tree_content: Dict) DistributedTree[source]#

secretflow.ml.boost.sgb_v.core.distributed_tree.split_tree#

Classes:

SplitTree()

Each party will hold one split tree.

Functions:

from_dict(dict)

is_left_node(node_index)

judge if a node is left node or right node from index root is view as left.

class secretflow.ml.boost.sgb_v.core.distributed_tree.split_tree.SplitTree[source]#

Bases: object

Each party will hold one split tree. Note this tree contains no leaf weights, but contains leaf indices.

Methods:

__init__()

insert_split_node(feature, value[, index])

extend_leaf_indices(leaf_indices)

predict_leaf_select(x)

compute leaf nodes' sample selects known by this partition.

to_dict()

__init__() None[source]#
insert_split_node(feature: int, value: float, index: int = 0) None[source]#
extend_leaf_indices(leaf_indices: List[int]) None[source]#
predict_leaf_select(x: ndarray) ndarray[source]#

compute leaf nodes’ sample selects known by this partition.

Parameters:
  • x – dataset from this partition.

  • tree – tree model store by this partition.

Returns:

List[np.array], length equals leaf number.

Return type:

leaf nodes’ selects

to_dict() Dict[source]#
secretflow.ml.boost.sgb_v.core.distributed_tree.split_tree.from_dict(dict: Dict) SplitTree[source]#
secretflow.ml.boost.sgb_v.core.distributed_tree.split_tree.is_left_node(node_index: int) bool[source]#

judge if a node is left node or right node from index root is view as left.