全表统计是指对整个数据表进行基本统计分析的方法。它计算并汇总数据集的各项统计指标,如均值、中位数、标准差、最小值、最大值、缺失值数量等。该算法用于快速了解数据的整体特征和质量,为后续的数据清洗、特征工程和模型构建提供基础信息。
配置组件
方式一:可视化方式
在Designer工作流页面添加全表统计组件,并在界面右侧配置相关参数:
参数类型 | 参数 | 描述 |
参数设置 | 输入列 | 指定哪些列要包含在统计分析中。默认情况下,会选择数据集中的所有列进行统计计算。 |
执行调优 | 核数目 | 节点个数。 |
内存数 | 单个节点内存大小。 |
方式二:PAI命令方式
使用PAI命令配置全表统计组件参数。您可以使用SQL脚本组件进行PAI命令调用,详情请参见场景4:在SQL脚本组件中执行PAI命令。
PAI -name stat_summary
-project algo_public
-DinputTableName=test_data
-DoutputTableName=test_summary_out
-DinputTablePartitions="ds='20160101'"
-DselectColNames=col0,col1,col2
-Dlifecycle=1
参数名称 | 是否必选 | 参数描述 |
inputTableName | 是 | 输入表名。 |
outputTableName | 是 | 输出表名。 |
inputTablePartitions | 否 | 输入表的分区,系统默认选择所有分区。 |
selectColNames | 否 | 需要统计的列名。 |
lifecycle | 否 | 输出结果表的生命周期,系统默认不设置生命周期。 |
coreNum | 否 | 节点数量。 |
memSizePerCore | 否 | 每个节点的内存数,取值范围[1024, 64*1024],单位MB。 |
使用示例
添加SQL脚本组件,去勾选使用Script模式和是否由系统添加Create Table语句,并在SQL脚本中输入以下SQL语句。
drop table if exists summary_test_input; create table summary_test_input as select * from ( select 'a' as col1, 1 as col2, 0.001 as col3 union all select 'b' as col1, 2 as col2, 100.01 as col3 ) tmp;
添加SQL脚本组件,去勾选使用Script模式和是否由系统添加Create Table语句,在SQL脚本中输入以下PAI命令,并将步骤 1和步骤 2的组件进行连线。
drop table if exists ${o1}; PAI -name stat_summary -project algo_public -DinputTableName=summary_test_input -DoutputTableName=${o1} -DselectColNames=col1,col2,col3 -Dlifecycle=1;
单击左上角
,运行工作流。
待运行结束,右键单击步骤 2的组件,选择查看数据 > SQL脚本的输出,查看训练结果。
| colname | datatype | totalcount | count | missingcount | nancount | positiveinfinitycount | negativeinfinitycount | min | max | mean | variance | standarddeviation | standarderror | skewness | kurtosis | moment2 | moment3 | moment4 | centralmoment2 | centralmoment3 | centralmoment4 | sum | sum2 | sum3 | sum4 | | ------- | -------- | ---------- | ----- | ------------ | -------- | --------------------- | --------------------- | ----- | ------ | ------- | ----------------- | ------------------ | ----------------- | --------------------- | ------------------ | ----------------- | ----------------- | ----------------- | -------------- | -------------------- | ----------------- | ------- | ------------ | ----------------- | -------------- | | col1 | string | 2 | 2 | 0 | 0 | 0 | 0 | | | | | | | | | | | | | | | | | | | | col2 | bigint | 2 | 2 | 0 | 0 | 0 | 0 | 1 | 2 | 1.5 | 0.5 | 0.7071067811865476 | 0.5 | 0 | -2 | 2.5 | 4.5 | 8.5 | 0.25 | 0 | 0.0625 | 3 | 5 | 9 | 17 | | col3 | double | 2 | 2 | 0 | 0 | 0 | 0 | 0.001 | 100.01 | 50.0055 | 5000.900040500001 | 70.71704207968544 | 50.00450000000001 | 2.327677906939552e-16 | -1.999999999999999 | 5001.000050500001 | 500150.0150005006 | 50020003.00020002 | 2500.45002025 | 2.91038304567337e-11 | 6252250.303768232 | 100.011 | 10002.000101 | 1000300.030001001 | 100040006.0004 |
列名
描述
colname
列名
datatype
类型
totalcount
总数
count
非NULL数量
missingcount
NULL数量
nancount
NAN数量
positiveinfinitycount
正无穷数量
negativeinfinitycount
负无穷数量
min
最小值
max
最大值
mean
平均值
variance
方差
standarddeviation
标准差
standarderror
标准误差
skewness
偏度
kurtosis
峰度
moment2
二阶矩
moment3
三阶矩
moment4
四阶矩
centralmoment2
二阶中心距
centralmoment3
三阶中心距
centralmoment4
四阶中心距
sum
总和
sum2
平方和
sum3
立方和
sum4
四次方和