secretflow.ml.boost.sgb_v.factory.components.sampler#

Classes:

Sampler()

class secretflow.ml.boost.sgb_v.factory.components.sampler.Sampler[源代码]#

基类:Component

Methods:

__init__()

show_params()

set_params(params)

get_params(params)

set_devices(_)

generate_col_choices(feature_buckets)

Generate column sample choices.

generate_row_choices(row_num)

apply_vector_sampling(x, indices)

Sample x for a single partition.

apply_v_fed_sampling(X[, row_choices, ...])

Sample X based on row choices and col choices.

__init__()[源代码]#
show_params()[源代码]#
set_params(params: dict)[源代码]#
get_params(params: dict)[源代码]#
set_devices(_: Devices)[源代码]#
generate_col_choices(feature_buckets: List[PYUObject]) Tuple[List[PYUObject], List[PYUObject]][源代码]#

Generate column sample choices.

参数:

feature_buckets (List[PYUObject]) – Behind PYUObject is List[int], bucket num for each feature.

返回:

first list is column choices, second is total number of buckets after sampling

返回类型:

Tuple[List[PYUObject], List[PYUObject]]

generate_row_choices(row_num) Union[None, ndarray][源代码]#
apply_vector_sampling(x: PYUObject, indices: Union[PYUObject, ndarray])[源代码]#

Sample x for a single partition. Assuming we have a column vector. Assume the indices was generated from row sampling by sampler

apply_v_fed_sampling(X: FedNdarray, row_choices: Union[None, ndarray, PYUObject] = None, col_choices: List[Union[None, ndarray, PYUObject]] = []) FedNdarray[源代码]#

Sample X based on row choices and col choices. Assume the choices were generated by sampler.

参数:
  • X (FedNdarray) – Array to sample from

  • row_choices (Union[None, np.ndarray, PYUObject]) – row sampling choices. devices are assumed to be ordered as X.

  • col_choices (List[Union[None, np.ndarray,PYUObject]) – col sampling choices. devices are assumed to be ordered as X.

返回:

subsampled X shape (Tuple[int, int]): shape of X_sub

返回类型:

X_sub (FedNdarray)

secretflow.ml.boost.sgb_v.factory.components.sampler.sampler#

Classes:

SamplerParams([row_sample_rate, ...])

'row_sample_rate': Row sub sample ratio of the training instances.

Sampler()

Functions:

generate_one_partition_col_choices(...)

class secretflow.ml.boost.sgb_v.factory.components.sampler.sampler.SamplerParams(row_sample_rate: float = 1, col_sample_rate: float = 1, seed: int = 1212)[源代码]#

基类:object

‘row_sample_rate’: Row sub sample ratio of the training instances.

default: 1 range: (0, 1]

‘col_sample_rate’: Col sub sample ratio of columns when constructing each tree.

default: 1 range: (0, 1]

‘seed’: Pseudorandom number generator seed.

default: 1212

Attributes:

row_sample_rate

col_sample_rate

seed

Methods:

__init__([row_sample_rate, col_sample_rate, ...])

row_sample_rate: float = 1#
col_sample_rate: float = 1#
seed: int = 1212#
__init__(row_sample_rate: float = 1, col_sample_rate: float = 1, seed: int = 1212) None#
class secretflow.ml.boost.sgb_v.factory.components.sampler.sampler.Sampler[源代码]#

基类:Component

Methods:

__init__()

show_params()

set_params(params)

get_params(params)

set_devices(_)

generate_col_choices(feature_buckets)

Generate column sample choices.

generate_row_choices(row_num)

apply_vector_sampling(x, indices)

Sample x for a single partition.

apply_v_fed_sampling(X[, row_choices, ...])

Sample X based on row choices and col choices.

__init__()[源代码]#
show_params()[源代码]#
set_params(params: dict)[源代码]#
get_params(params: dict)[源代码]#
set_devices(_: Devices)[源代码]#
generate_col_choices(feature_buckets: List[PYUObject]) Tuple[List[PYUObject], List[PYUObject]][源代码]#

Generate column sample choices.

参数:

feature_buckets (List[PYUObject]) – Behind PYUObject is List[int], bucket num for each feature.

返回:

first list is column choices, second is total number of buckets after sampling

返回类型:

Tuple[List[PYUObject], List[PYUObject]]

generate_row_choices(row_num) Union[None, ndarray][源代码]#
apply_vector_sampling(x: PYUObject, indices: Union[PYUObject, ndarray])[源代码]#

Sample x for a single partition. Assuming we have a column vector. Assume the indices was generated from row sampling by sampler

apply_v_fed_sampling(X: FedNdarray, row_choices: Union[None, ndarray, PYUObject] = None, col_choices: List[Union[None, ndarray, PYUObject]] = []) FedNdarray[源代码]#

Sample X based on row choices and col choices. Assume the choices were generated by sampler.

参数:
  • X (FedNdarray) – Array to sample from

  • row_choices (Union[None, np.ndarray, PYUObject]) – row sampling choices. devices are assumed to be ordered as X.

  • col_choices (List[Union[None, np.ndarray,PYUObject]) – col sampling choices. devices are assumed to be ordered as X.

返回:

subsampled X shape (Tuple[int, int]): shape of X_sub

返回类型:

X_sub (FedNdarray)

secretflow.ml.boost.sgb_v.factory.components.sampler.sampler.generate_one_partition_col_choices(colsample, feature_buckets: List[int]) Tuple[Union[None, ndarray], int][源代码]#