如果一个饲料如何说100个不同的病例进入神经网络包中的神经网络neuralnet()函数,而无需输入它们。
如果有一个带有colnames(df) = "one","two","three"..."one hundred"的数据帧
我想使用每一列作为神经网络的输入,有没有办法应用神经网络功能:
nn <- neuralnet(one~two+three+four+five+six+seven+eight...+one hundred, data=df, err.fct = 'sse', linear.output = F, likelihood=T)没有实际输入所有一百个名字。
我试过输入:
nn <- neuralnet(one~as.factor(paste(names(df)[-1], collapse="+")) data=df, err.fct = 'sse', linear.output = F, likelihood=T)并收到错误
Error in model.frame.default(formula.reverse, data) : variable lengths differ (found for 'as.factor(paste(names(df)[-1], collapse="+"))')How would one feed say, 100 different cases into the neuralnet() function found in the neuralnet package without maunally inputting them.
If there is a dataframe with colnames(df) = "one","two","three"..."one hundred"
and I want to use each column as an input into a neural network, is there a way to apply the neuralnet function as such:
nn <- neuralnet(one~two+three+four+five+six+seven+eight...+one hundred, data=df, err.fct = 'sse', linear.output = F, likelihood=T)without actually typing all one hundred colnames.
I have tried inputting:
nn <- neuralnet(one~as.factor(paste(names(df)[-1], collapse="+")) data=df, err.fct = 'sse', linear.output = F, likelihood=T)and recieved the error
Error in model.frame.default(formula.reverse, data) : variable lengths differ (found for 'as.factor(paste(names(df)[-1], collapse="+"))')最满意答案
可能是一个重复的问题。 编辑:@Hong Ooi指出“点解决方案”在neuralnet()不起作用。
dta <- data.frame(a=rnorm(10), a2=rnorm(10), a3=rnorm(10)) frm <- as.formula(paste(names(dta)[1], " ~ ", paste(names(dta)[-1], collapse= "+"))) nn <- neuralnet(frm, data=dta, err.fct = 'sse', linear.output = F, likelihood=T)Might be a duplicate question. Edit: @Hong Ooi pointed out the "dot solution" doesnt work in neuralnet().
dta <- data.frame(a=rnorm(10), a2=rnorm(10), a3=rnorm(10)) frm <- as.formula(paste(names(dta)[1], " ~ ", paste(names(dta)[-1], collapse= "+"))) nn <- neuralnet(frm, data=dta, err.fct = 'sse', linear.output = F, likelihood=T)更多推荐
发布评论