Weighted sampling
This component generates sample data using weighted sampling. The weight column must be of the DOUBLE or BIGINT data type. Records are sampled based on the values in this column. For example, a record with a weight of 1.2 has a higher probability of being sampled than a record with a weight of 1.0.
Configure the component
You can configure the parameters for the Weighted Sampling component in one of the following ways.
Method 1: Use the GUI
You can configure the component parameters on the workflow page in Designer.
Tab | Parameter | Description |
Parameters setting | Sample size | A positive integer. |
Sampling ratio | A floating-point number in the range of (0, 1). | |
Sampling with replacement | Select this option to enable sampling with replacement. By default, sampling is performed without replacement. | |
Weight column | Select a column to use for weighting. The column must be of the DOUBLE or BIGINT type. Each value represents the weight of the corresponding record. Normalization is not required. | |
Random seed | The system generates this by default. | |
Execution tuning | Number of cores | The value must be a positive integer. The system automatically assigns a default value. |
Kernel Memory Allocation | A positive integer in the range of (1, 65536). The system automatically allocates the memory by default. |
Method 2: Use a PAI command
You can configure the component parameters using a PAI command in the SQL script component. For more information, see SQL script.
PAI -name WeightedSample
-project algo_public
-Dlifecycle="28"
-DoutputTableName="test2"
-DprobCol="previous"
-Dreplace="false"
-DsampleSize="500"
-DinputPartitions="pt=20150501"
-DinputTableName="bank_data_partition";Parameter Name | Required | Description | Default value |
inputTableName | Yes | The name of the input table. | None |
inputTablePartitions | No | The partitions in the input table to use for training. The following formats are supported:
Note If you specify multiple partitions, separate them with commas (,). | All partitions |
outputTableName | Yes | The output table. | None |
sampleSize | No | The number of samples to generate. Note
| None |
sampleRatio | No | The sampling ratio. This parameter specifies a floating-point number in the range of (0, 1). | None |
probCol | Yes | The column to use for weighting. Each value represents the weight of the corresponding record. Normalization is not required. The column must be of the DOUBLE or BIGINT type. | None |
replace | No | Specifies whether to perform sampling with replacement. This parameter is of the BOOLEAN type. | false (Sampling without replacement is performed by default.) |
randomSeed | No | The random seed. The value must be a positive integer. | The system automatically assigns a value. |
lifecycle | No | The lifecycle of the output table in days. The value must be an integer in the range of [1, 3650]. | None |
coreNum | No | The number of cores for computing. The value must be a positive integer. | The system assigns this automatically. |
memSizePerCore | No | The memory size for each core, in MB. The value must be an integer in the range of (1, 65536). | This is automatically assigned by the system. |