ALINK(三十二):特征工程(十一)特征选择(三)向量卡方选择器 (VectorChiSqSelectorBatchOp)
2021/6/19 0:03:04
本文主要是介绍ALINK(三十二):特征工程(十一)特征选择(三)向量卡方选择器 (VectorChiSqSelectorBatchOp),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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|
这篇关于ALINK(三十二):特征工程(十一)特征选择(三)向量卡方选择器 (VectorChiSqSelectorBatchOp)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-04安装 Eyoucms详细图文教程-icode9专业技术文章分享
- 2024-07-04ueditor 复制文章时,图片的链接是一个下载图片地址,该如何处理?-icode9专业技术文章分享
- 2024-07-04怎样判断host有没有对wordpress有缓存呢-icode9专业技术文章分享
- 2024-07-04具有编译功能的系统make后,无法ssh连接-icode9专业技术文章分享
- 2024-07-04make后如何升级ssh-icode9专业技术文章分享
- 2024-07-03微信支付提示下单账户与支付账户不一致-icode9专业技术文章分享
- 2024-07-03微信支付提示订单号重复-icode9专业技术文章分享
- 2024-07-02微服务启动nacos注册上去了,但是一直没有收到请求-icode9专业技术文章分享
- 2024-07-02如何检查文件的编码格式-icode9专业技术文章分享
- 2024-07-02sublime 更改编码格式-icode9专业技术文章分享