Federated Sampling¶
From Fate v0.2 supports sample method. Sample module supports threee sample modes: random sample mode, stratified sample mode, and exact sample by weight.
-
In random mode, "downsample" and "upsample" methods are provided. Users can set the sample parameter "fractions", which is the sample ratio within data.
-
In stratified mode, "downsample" and "upsample" methods are also provided. Users can set the sample parameter "fractions" too, but it should be a list of tuples in the form (label_i, ratio). Tuples in the list each specify the sample ratio of corresponding label. e.g.
-
When using
exact_by_weight
mode, samples will be duplicatedceil(weight)
copies. Any zero-weighted samples will be discarded. Note that this mode requires that instances have match id: please setextend_sid
in configuration when uploading data for this sample mode.
[(0, 1.5), (1, 2.5), (3, 3.5)]
Param¶
sample_param
¶
Classes¶
SampleParam(mode='random', method='downsample', fractions=None, random_state=None, task_type='hetero', need_run=True)
¶
Bases: BaseParam
Define the sample method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode |
specify sample to use, default: 'random' |
'random'
|
fractions: None or float or list if mode equals to random, it should be a float number greater than 0, otherwise a list of elements of pairs like [label_i, sample_rate_i], e.g. [[0, 0.5], [1, 0.8], [2, 0.3]]. default: None
random_state: int, RandomState instance or None, default: None random state
need_run: bool, default True Indicate if this module needed to be run
Source code in python/federatedml/param/sample_param.py
47 48 49 50 51 52 53 54 |
|
Attributes¶
mode = mode
instance-attribute
¶method = method
instance-attribute
¶fractions = fractions
instance-attribute
¶random_state = random_state
instance-attribute
¶task_type = task_type
instance-attribute
¶need_run = need_run
instance-attribute
¶Functions¶
check()
¶Source code in python/federatedml/param/sample_param.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|