文档

边聚类系数

更新时间:

边聚类系数表示在无向图中每一条边周围的稠密度,边聚类系数组件能够输出各边节点的相邻节点数量及边的稠密度。

配置组件

方法一:可视化方式

在Designer工作流页面添加边聚类系数组件,并在界面右侧配置相关参数:

参数类型

参数

描述

字段设置

起始节点

边表的起点所在列。

终止节点

边表的终点所在列。

执行调优

进程数量

作业并行执行的节点数。数字越大并行度越高,但是框架通讯开销会增大。

进程内存

单个作业可使用的最大内存量,单位:MB,默认值为4096。

如果实际使用内存超过该值,会抛出OutOfMemory异常。

数据切分大小

数据切分的大小,单位:MB,默认值为64。

方法二:PAI命令方式

使用PAI命令配置边聚类系数组件参数。您可以使用SQL脚本组件进行PAI命令调用,详情请参见场景4:在SQL脚本组件中执行PAI命令

PAI -name EdgeDensity
    -project algo_public
    -DinputEdgeTableName=EdgeDensity_func_test_edge
    -DfromVertexCol=flow_out_id
    -DtoVertexCol=flow_in_id
    -DoutputTableName=EdgeDensity_func_test_result;

参数

是否必选

默认值

描述

inputEdgeTableName

输入边表名。

inputEdgeTablePartitions

全表读入

输入边表的分区。

fromVertexCol

输入边表的起点所在列。

toVertexCol

输入边表的终点所在列。

outputTableName

输出表名。

outputTablePartitions

输出表的分区。

lifecycle

输出表的生命周期。

workerNum

未设置

作业并行执行的节点数。数字越大并行度越高,但是框架通讯开销会增大。

workerMem

4096

单个作业可使用的最大内存量,单位:MB,默认值为4096。

如果实际使用内存超过该值,会抛出OutOfMemory异常。

splitSize

64

数据切分的大小,单位:MB。

使用示例

  1. 添加SQL脚本组件,输入以下SQL语句生成训练数据。

    drop table if exists EdgeDensity_func_test_edge;
    create table EdgeDensity_func_test_edge as
    select * from
    (
      select '1' as flow_out_id,'2' as flow_in_id
      union all
      select '1' as flow_out_id,'3' as flow_in_id
      union all
      select '1' as flow_out_id,'5' as flow_in_id
      union all
      select '1' as flow_out_id,'7' as flow_in_id
      union all
      select '2' as flow_out_id,'5' as flow_in_id
      union all
      select '2' as flow_out_id,'4' as flow_in_id
      union all
      select '2' as flow_out_id,'3' as flow_in_id
      union all
      select '3' as flow_out_id,'5' as flow_in_id
      union all
      select '3' as flow_out_id,'4' as flow_in_id
      union all
      select '4' as flow_out_id,'5' as flow_in_id
      union all
      select '4' as flow_out_id,'8' as flow_in_id
      union all
      select '5' as flow_out_id,'6' as flow_in_id
      union all
      select '5' as flow_out_id,'7' as flow_in_id
      union all
      select '5' as flow_out_id,'8' as flow_in_id
      union all
      select '7' as flow_out_id,'6' as flow_in_id
      union all
      select '6' as flow_out_id,'8' as flow_in_id
    )tmp;
    drop table if exists EdgeDensity_func_test_result;
    create table EdgeDensity_func_test_result
    (
      node1 string,
      node2 string,
      node1_edge_cnt bigint,
      node2_edge_cnt bigint,
      triangle_cnt bigint,
      density double
    );

    对应的数据结构图:

    image

  2. 添加SQL脚本组件,输入以下PAI命令进行训练。

    drop table if exists ${o1};
    PAI -name EdgeDensity
        -project algo_public
        -DinputEdgeTableName=EdgeDensity_func_test_edge
        -DfromVertexCol=flow_out_id
        -DtoVertexCol=flow_in_id
        -DoutputTableName=${o1};
  3. 右击上一步的组件,选择查看数据 > SQL脚本的输出,查看训练结果。

    | node1 | node2 | node1_edge_cnt | node2_edge_cnt | triangle_cnt | density |
    | ----- | ----- | -------------- | -------------- | ------------ | ------- |
    | 3     | 1     | 4              | 4              | 2            | 0.5     |
    | 5     | 1     | 7              | 4              | 3            | 0.75    |
    | 7     | 1     | 3              | 4              | 1            | 0.33333 |
    | 1     | 2     | 4              | 4              | 2            | 0.5     |
    | 4     | 2     | 4              | 4              | 2            | 0.5     |
    | 2     | 3     | 4              | 4              | 3            | 0.75    |
    | 5     | 3     | 7              | 4              | 3            | 0.75    |
    | 3     | 4     | 4              | 4              | 2            | 0.5     |
    | 8     | 4     | 3              | 4              | 1            | 0.33333 |
    | 2     | 5     | 4              | 7              | 3            | 0.75    |
    | 4     | 5     | 4              | 7              | 3            | 0.75    |
    | 7     | 5     | 3              | 7              | 2            | 0.66667 |
    | 5     | 6     | 7              | 3              | 2            | 0.66667 |
    | 8     | 6     | 3              | 3              | 1            | 0.33333 |
    | 6     | 7     | 3              | 3              | 1            | 0.33333 |
    | 5     | 8     | 7              | 3              | 2            | 0.66667 |
  • 本页导读 (1)
文档反馈