我有一个数据框
> str(dataset)
'data.frame': 2354 obs. of 11 variables:
$ SessionID : int 11 12 21 21 22 26 33 33 33 46 ...
$ ItemID : int 214821371 214717867 214548744 214838503 214837487 214714790 214706441 214820225 214834865 214716932 ...
$ n : int 2 1 1 1 1 1 2 2 2 4 ...
$ diffinscnd : num 6.68 0 0.053 0.053 0 ...
$ total_clicks : int 2 1 2 2 1 1 6 6 6 4 ...
$ unique_Category: int 1 1 1 1 1 1 1 1 1 1 ...
$ unique_items : int 1 1 2 2 1 1 3 3 3 1 ...
$ Class : int 0 0 0 0 0 0 0 0 0 0 ...
$ mean.Class. : num 0 0 0 0 0 0 0 0 0 0 ...
$ avg : num 0 0 0 0 0 0 0 0 0 0 ...
$ Category : int 0 0 0 0 0 0 0 0 0 0 ...
当我尝试使用下面的代码来应用神经网络时
> set.seed(123)
> smp_size <- floor(0.80 * nrow(dataset))
> train_ind <- sample(seq_len(nrow(dataset)), size = smp_size)
> trainset <- dataset[train_ind, ]
> testset <- dataset[-train_ind, ]
> maxs <- apply(dataset, 2, max)
> mins <- apply(dataset, 2, min)
> scaled <- as.data.frame(scale(dataset, center = mins, scale = maxs - mins))
> trainNN = scaled[train_ind , ]
> testNN = scaled[-train_ind , ]
> creditnet <- neuralnet(Category ~ SessionID + ItemID + n + diffinscnd + total_clicks + unique_Category + unique_items + Class + avg, trainNN,hidden = 3, lifesign = "minimal",linear.output = FALSE, threshold = 0.1)
然后我遇到了以下错误
hidden: 3 thresh: 0.1 rep: 1/1 steps: Error in x - y : non-conformable arrays In addition: Warning message: In cbind(1, act.temp) : number of rows of result is not a multiple of vector length (arg 1)
如何解决此错误?