本文为您介绍PAI-Designer(原PAI-Studio)提供的离散值特征分析。

离散值特征分析统计离散特征的分布情况。包括gini,entropy,gini gain,information gain,information gain ratio等指标。计算每个离散值对应的gini,entropy,计算单列对应的gini gain,information gain,information gain ratio。
  • gini index:index
  • entropy:entropy

组件配置

您可以使用以下任意一种方式,配置离散值特征分析组件参数。

方式一:可视化方式

在PAI-Designer(原PAI-Studio)工作流页面配置组件参数。
参数 描述
特征列 用来表现训练样本数据特征的列。
标签列 标签字段。
稀疏矩阵 当输入表数据为稀疏格式时,需要设置KV格式的特征。

方式二:PAI命令方式

使用PAI命令方式,配置该组件参数。您可以使用SQL脚本组件进行PAI命令调用,详情请参见SQL脚本
PAI
-name enum_feature_selection
-project algo_public
-DinputTableName=enumfeautreselection_input
-DlabelColName=label
-DfeatureColNames=col0,col1
-DenableSparse=false
-DoutputCntTableName=enumfeautreselection_output_cntTable
-DoutputValueTableName=enumfeautreselection_output_valuetable
-DoutputEnumValueTableName=enumfeautreselection_output_enumvaluetable;
参数名称 是否必选 描述 默认值
inputTableName 输入表的名称。
inputTablePartitions 输入表中,参与训练的分区。系统支持以下格式:
  • Partition_name=value
  • name1=value1/name2=value2:多级分区
说明 指定多个分区时,分区之间使用英文逗号(,)分隔。
默认选择全表
featureColNames 输入表中,用于训练的特征列名。
labelColName 输入表中,标签列的名称。
enableSparse 输入数据是否为稀疏格式,取值范围为{true,false} false
kvFeatureColNames KV格式的特征。 默认选择全表
kvDelimiter 当输入表数据为稀疏格式时,keyvalue之间的分隔符。 英文冒号(:)
itemDelimiter 当输入表数据为稀疏格式时,KV对之间的分隔符。 英文逗号(,)
outputCntTableName 输出离散特征的枚举值分布数表。 不涉及
outputValueTableName 输出离散特征的gini、entropy表。 不涉及
outputEnumValueTableName 输出离散特征枚举值gini、entropy表。 不涉及
lifecycle 表的生命周期。
coreNum 计算的核心数,取值范围为正整数。 系统自动分配
memSizePerCore 每个核心的内存,取值范围为1 MB~65536 MB。 系统自动分配

示例

使用如下SQL语句,生成输入数据。
drop table if exists enum_feature_selection_test_input;
create table enum_feature_selection_test_input
as
select
    *
from
(
    select
        '00' as col_string,
        1 as col_bigint,
        0.0 as col_double
    from dual
    union all
        select
            cast(null as string) as col_string,
            0 as col_bigint,
            0.0 as col_double
        from dual
    union all
        select
            '01' as col_string,
            0 as col_bigint,
            1.0 as col_double
        from dual
    union all
        select
            '01' as col_string,
            1 as col_bigint,
            cast(null as double) as col_double
        from dual
    union all
        select
            '01' as col_string,
            1 as col_bigint,
            1.0 as col_double
        from dual
    union all
        select
            '00' as col_string,
            0 as col_bigint,
            0.0 as col_double
        from dual
) tmp;
输入数据如下所示。
+------------+------------+------------+
| col_string | col_bigint | col_double |
+------------+------------+------------+
| 01         | 1          | 1.0        |
| 01         | 0          | 1.0        |
| 01         | 1          | NULL       |
| NULL       | 0          | 0.0        |
| 00         | 1          | 0.0        |
| 00         | 0          | 0.0        |
+------------+------------+------------+
  • PAI命令方式
    • 运行命令
      drop table if exists enum_feature_selection_test_input_enum_value_output;
      drop table if exists enum_feature_selection_test_input_cnt_output;
      drop table if exists enum_feature_selection_test_input_value_output;
      PAI -name enum_feature_selection -project algo_public -DitemDelimiter=":" -Dlifecycle="28" -DoutputValueTableName="enum_feature_selection_test_input_value_output" -DkvDelimiter="," -DlabelColName="col_bigint" -DfeatureColNames="col_double,col_string" -DoutputEnumValueTableName="enum_feature_selection_test_input_enum_value_output" -DenableSparse="false" -DinputTableName="enum_feature_selection_test_input" -DoutputCntTableName="enum_feature_selection_test_input_cnt_output";
    • 运行结果
      • enum_feature_selection_test_input_cnt_output
        +------------+------------+------------+------------+
        | colname    | colvalue   | labelvalue | cnt        |
        +------------+------------+------------+------------+
        | col_double | NULL       | 1          | 1          |
        | col_double | 0          | 0          | 2          |
        | col_double | 0          | 1          | 1          |
        | col_double | 1          | 0          | 1          |
        | col_double | 1          | 1          | 1          |
        | col_string | NULL       | 0          | 1          |
        | col_string | 00         | 0          | 1          |
        | col_string | 00         | 1          | 1          |
        | col_string | 01         | 0          | 1          |
        | col_string | 01         | 1          | 2          |
        +------------+------------+------------+------------+
      • enum_feature_selection_test_input_value_output
        +------------+------------+------------+------------+------------+---------------+
        | colname    | gini       | entropy    | infogain   | ginigain   | infogainratio |
        +------------+------------+------------+------------+------------+---------------+
        | col_double | 0.3888888888888889 | 0.792481250360578 | 0.20751874963942196 | 0.1111111111111111 | 0.14221913160264427 |
        | col_string | 0.38888888888888884 | 0.792481250360578 | 0.20751874963942196 | 0.11111111111111116 | 0.14221913160264427 |
        +------------+------------+------------+------------+------------+---------------+
      • enum_feature_selection_test_input_enum_value_output
        +------------+------------+------------+------------+
        | colname    | colvalue   | gini       | entropy    |
        +------------+------------+------------+------------+
        | col_double | NULL       | 0.0        | 0.0        |
        | col_double | 0          | 0.22222222222222224 | 0.4591479170272448 |
        | col_double | 1          | 0.16666666666666666 | 0.3333333333333333 |
        | col_string | NULL       | 0.0        | 0.0        |
        | col_string | 00         | 0.16666666666666666 | 0.3333333333333333 |
        | col_string | 01         | 0.2222222222222222 | 0.4591479170272448 |
        +------------+------------+------------+------------+
  • 可视化方式
    • 组件界面组件
    • 参数设置参数设置
    • 运行结果运行结果