特征筛选(变量聚类proc varclus)

在特征工程筛选变量的时候,我们可以用varclus进行变量的聚类分析来进行降维。

proc varclus

The VARCLUS procedure divides a set of numeric variables into disjoint or hierarchical clusters. Associated with each cluster is a linear combination of the variables in the cluster.

varclus过程首先是将所有的变量聚类成一簇,求相关矩阵的特征值,然后根据设置的参数来拆分聚类

“A cluster is chosen for splitting. Depending on the options specified, the selected cluster has either the smallest percentage of variation explained by its cluster component (using the PROPORTION= option) or the largest eigenvalue associated with the second principal component (using the MAXEIGEN= option)”

拆分的条件是已拆分好的簇能达到解释变异的最小百分比(如设置为PROPORTION=0.75,目前拆分3个簇只能解释70%,则继续拆分);或者有满足第二特征根大于MAXEIGEN存在,通常设置为1或0.7。
在这里插入图片描述
上面拆分2簇,第1簇的第二大特征值为0.9379,第2簇的第二大特征值为0.456,两簇总解释的偏差为61.29%,可以选择继续拆分第1簇。
在这里插入图片描述
上图中1-R^2 = 下一个最靠近的R方/自己的聚类的R方,因此1-R方最小,则变量更能代表该簇。

上面是最终拆分的结果,然后挑选变量有以下2条原则:变量的业务解释和1-R^2
变量的业务解释包含很多方面,如:最近X个月的变量,有时会选择6个月,有时会偏好选择3个月;考虑客户不同维度变量:收入、负债、额度、账龄、额度使用率、分期、取现、逾期,最后每个维度都能有代表性变量。

在实际模型开发过程中,变量很多的时候,可以将上图R方统计分析输出(代码如下),并与iv值等筛选逻辑合并,然后统一筛选。

ods output 
RSquare=r2;
proc varclus data=&inDS maxeigen=&maxeigen
	outstat=&outstat
	outtree=&outtree
	hi  ;

	%inc var;
	
run;quit;
proc sql noprint;
	select max(_NCL_) into: max_cluster_num from &outstat;
quit;

data &outr2;
   set r2;
   where NumberOfClusters=&max_cluster_num;
run;

附:
1、https://bbs.pinggu.org/thread-3036735-1-1.html
3、http://blog.sina.com.cn/s/blog_5d3b177c0100equm.html
4、主成分分析与因子分析(1)
5、主成分分析与因子分析(2)

  • 7
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值