我正在寻找受监督的PCA,以减少数据的维数。对于这种情况,首先,我需要使受监督的PCA适合训练数据,然后使用以前用于训练数据的pca转换测试数据。我从这个link找到了superpc库。但是,对于此代码,我无法通过pca获得简化的训练数据。
library(superpc)
set.seed(464)
x<-matrix(rnorm(1000*100),ncol=100)
v1<- svd(x[1:80,])$v[,1]
y<-2+5*v1+ .05*rnorm(100)
xtest<-x
ytest<-2+5*v1+ .05*rnorm(100)
censoring.status<- sample(c(rep(1,80),rep(0,20)))
censoring.status.test<- sample(c(rep(1,80),rep(0,20)))
featurenames <- paste("feature",as.character(1:1000),sep="")
data<-list(x=x,y=y, censoring.status= censoring.status, featurenames=featurenames)
data.test<-list(x=xtest,y=ytest, censoring.status=censoring.status.test, featurenames= featurenames)
train.obj<- superpc.train(data, type="survival")
fit.cts<- superpc.predict(train.obj, data, data.test, threshold=0.7, n.components=3, prediction.type="continuous")
View(fit.cts$v.pred)
我也不确定fit.cts<- superpc.predict(train.obj, data, data.test, threshold=0.7, n.components=3, prediction.type="continuous")
是否返回测试数据或训练数据的简化版本。