R:Laplacian分布筛选特征
转自:do.lscore,https://www.rdocumentation.org/packages/Rdimtools/versions/1.0.4
1.例子
data(iris) set.seed(100) subid <- sample(1:150, 50) iris.dat <- as.matrix(iris[subid,1:4])#输入是4维的 iris.lab <- as.factor(iris[subid,5])#第5列作为label library(Rdimtools) out1 = do.lscore(iris.dat, t=0.1)#不同的带宽t有什么区别呢? out2 = do.lscore(iris.dat, t=1) out3 = do.lscore(iris.dat, t=10) plot(out3$Y, pch=19, col=iris.lab, xlab="axis 1", ylab="axis 2", main="Laplacian Score")
函数原型:
do.lscore( X, ndim = 2,#默认降到2维 type = c("proportion", 0.1), preprocess = c("null", "center", "scale", "cscale", "whiten", "decorrelate"),#预处理,默认为null t = 10#带宽 )
2.返回结果
y:(n.n_dims)
这里的1和2是iris.dat所保留的特征3/4列的原数据,它不像PCA那样是找出主成分,这个是直接对特征打分,筛选出特征的。
lscore:a length-p vector of laplacian scores. Indices with smallest values are selected.特征分数,选择分数小的特征,这里是3/4.
featidx: a length-ndim vector of indices with highest scores.
trfinfo:包含样本外预测信息的列表。(不太理解)
projection:a (p×ndim) whose columns are basis for projection. 列是投影的基础。
3.可视化结果
iris部分数据可视化