ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ALINK(三十二):特征工程(十一)特征选择(三)向量卡方选择器 (VectorChiSqSelectorBatchOp)

2021-06-18 23:34:25  阅读:182  来源: 互联网

标签:特征选择 0.0 0.05 ALINK VectorChiSqSelectorBatchOp import 默认值 选择器 Row


Java 类名:com.alibaba.alink.operator.batch.feature.VectorChiSqSelectorBatchOp

Python 类名:VectorChiSqSelectorBatchOp

功能介绍

针对vector数据,进行特征筛选

参数说明

名称

中文名称

描述

类型

是否必须?

默认值

labelCol

标签列名

输入表中的标签列名

String

 

selectedCol

选中的列名

计算列对应的列名

String

 

selectorType

筛选类型

筛选类型,包含"NumTopFeatures","percentile", "fpr", "fdr", "fwe"五种。

String

 

"NumTopFeatures"

numTopFeatures

最大的p-value列个数

最大的p-value列个数, 默认值50

Integer

 

50

percentile

筛选的百分比

筛选的百分比,默认值0.1

Double

 

0.1

fpr

p value的阈值

p value的阈值,默认值0.05

Double

 

0.05

fdr

发现阈值

发现阈值, 默认值0.05

Double

 

0.05

fwe

错误率阈值

错误率阈值, 默认值0.05

Double

 

0.05

代码示例

Python 代码

无python接口

Java 代码

package javatest.com.alibaba.alink.batch.feature;
import org.apache.flink.types.Row;
import com.alibaba.alink.operator.batch.BatchOperator;
import com.alibaba.alink.operator.batch.feature.VectorChiSqSelectorBatchOp;
import com.alibaba.alink.operator.batch.source.MemSourceBatchOp;
import org.junit.Test;
import java.util.Arrays;
public class VectorChiSqSelectorBatchOpTest {
  @Test
  public void testVectorChiSqSelectorBatchOp() throws Exception {
    Row[] testArray = new Row[] {
      Row.of(7, "0.0  0.0  18.0  1.0", 1.0),
      Row.of(8, "0.0  1.0  12.0  0.0", 0.0),
      Row.of(9, "1.0  0.0  15.0  0.1", 0.0),
    };
    String[] colNames = new String[] {"id", "features", "clicked"};
    MemSourceBatchOp source = new MemSourceBatchOp(Arrays.asList(testArray), colNames);
    VectorChiSqSelectorBatchOp test = new VectorChiSqSelectorBatchOp()
      .setSelectedCol("features")
      .setLabelCol("clicked");
    test.linkFrom(source);
    test.lazyPrintModelInfo();
    BatchOperator.execute();
  }
}

 

运行结果

------------------------- ChisqSelectorModelInfo -------------------------
Number of Selector Features: 4
Number of Features: 4
Type of Selector: NumTopFeatures
Number of Top Features: 50
Selector Indices: 
    |VectorIndex|ChiSquare|PValue| DF|Selected|
    |-----------|---------|------|---|--------|
    |          3|        3|0.2231|  2|    true|
    |          2|        3|0.2231|  2|    true|
    |          0|     0.75|0.3865|  1|    true|
    |          1|     0.75|0.3865|  1|    true|

 

 

 

 

标签:特征选择,0.0,0.05,ALINK,VectorChiSqSelectorBatchOp,import,默认值,选择器,Row
来源: https://www.cnblogs.com/qiu-hua/p/14901601.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有