Federated Sampling¶
From Fate v0.2 supports sample method. Sample module supports two sample modes: random sample mode and stratified sample mode.
- 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.
[(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'
|
|
method |
specify sample method |
'downsample'
|
|
fractions |
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 |
None
|
|
random_state |
random state |
None
|
|
need_run |
Indicate if this module needed to be run |
True
|
Source code in federatedml/param/sample_param.py
42 43 44 45 46 47 48 49 |
|
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 federatedml/param/sample_param.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|