library(neuralnet)
# 数据载入及处理
data(iris)
dat <- iris
dat$Species <-as.numeric(dat$Species) #将分类划数值型
# 划分训练集和测试集
set.seed(20150904)
ind<-sample(2,nrow(dat),replace=TRUE,prob = c(0.7,0.3))
train_dat <-dat[ind==1,]
test_dat <- dat[ind==2,]
myFormula<- Species ~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width
model <-neuralnet(Species ~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,hidden=1,data = train_dat, act.fct = "logistic",)
plot(model)
pre<-compute(model, test_dat[1:4], rep = 1)
result_pre<- pre$net.result
table(test_dat$Species,result_pre)
neuralnet包做神经网络预测分类,如何才能实现呢?我这不能实现分类的预测,请大侠指教