나는 정말로 이것에 집착했습니다. 누구든지 저를 도울 수 있기를 바랍니다! 나는 54 개의 컬럼으로 이루어진 데이터 세트를 가지고 있고, ridge regression을 가진 테스트 세트에 대한 예측을하고 싶다.R ridge regression의 예측 R
nn <-nrow(longley)
index <- 1:nrow(longley)
testindex <- sample(index, trunc(length(index)/3))
testset <- longley[testindex,]
trainset <-longley[-testindex,]
trainset1 <- trainset[,-7]
# Fit the ridge regression model:
mod <- lm.ridge(y ~., data = trainset, lambda = 0.661)
# Predict and evaluate it by using MAE function:
mae <- function(model) {
y = trainset$Employed
y.pred <- predict(model, trainset)
return(mean(abs(y-y.pred)))
}
나는이 작업을 수행 할 때 내가 얻을 다음과 같은 오류 메시지가
Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "ridgelm"
(rsquared와 MAE로 또한 평가 지표와) 작동 능선 회귀와 예측을하는 또 다른 방법이 될 수 무엇?