将预测函数应用于kpca对象时出错

时间:2018-07-10 04:52:28

标签: r

将kpca应用于我的数据集后,出现以下错误:

  

training_set_pca <-as.data.frame(预测(kpca,training_set))   UseMethod(“ predict”)中的错误:     没有适用于“预测”的适用方法,该方法适用于类别为“ c('standardGeneric','genericFunction','function','OptionalFunction','PossibleMethod','kfunction','optionalMethod')的对象” \

代码:

df <-  read.csv("file:///D:/Dementia Risk Prediction Framework/Feature Selection/Input/Model-3_MMSE.csv")

df <-  df[,2:40]

head(df)

library(caTools)
library(e1071)
library(caret)
set.seed(123)
split <- sample.split(df$MMSE, SplitRatio = 0.75)
training_set <- subset(df, split == TRUE)
test_set <- subset(df, split == FALSE)



library(kernlab)
kpc <-  kpca(~.,data = training_set[,-39], kernel = 'rbfdot',features=2)



eigenvalues <- eig(kpc)

eigenvalues <- data.frame(eigenvalues)

eigenvalues <<- eigenvalues



training_set_pca <-  as.data.frame(predict(kpca, training_set))

training_set_pca$MMSE <-  training_set$MMSE

0 个答案:

没有答案