在R中使用neuralnet
包的compute()
函数时出现错误。
这是因为数据量太大导致的吗?我无法确定确切的问题。
df2 <- read.csv("data.csv")
train_df <- df2[1:3200,]
test_df <- df2[3201:4004,]
n <- names(train_df)
f <- as.formula(paste("tenure ~", paste(n[!n %in% "tenure"], collapse =
"+")))
model2 <- neuralnet(f,train_df, hidden=3, threshold=0.01, linear.output=T)
summary(model2)
#Output
Length Class Mode
call 6 -none- call
response 3200 -none- numeric
covariate 4118400 -none- numeric
model.list 2 -none- list
err.fct 1 -none- function
act.fct 1 -none- function
linear.output 1 -none- logical
data 1288 data.frame list
net.result 1 -none- list
weights 1 -none- list
startweights 1 -none- list
generalized.weights 1 -none- list
result.matrix 3871 -none- numeric
results <- compute(model2, test_df)
#Error
Error in UseMethod("compute"): no applicable method for 'compute' applied
to an object of class "nn"
Traceback:
1. compute(model2, test_df)
P.S:数据列是数字。