作者KKbiger (UUUU)
看板R_Language
标题Re: [问题] 关於类神经网络模型选择
时间Sun Oct 1 22:54:21 2017
※ 引述《asdfrtg (asdfrtg)》之铭言:
: [问题类型]:
: 程式谘询(我想用R 做某件事情,但是我不知道要怎麽用R 写出来)
: [软体熟悉度]:
: 新手(没写过程式,R 是我的第一次)
: [问题叙述]:
: 我想用train这个指令进行模型选择 可是跑出一大堆警告
: 并且所有出来的结果都是遗失值
: [程式范例]:
: library(neuralnet)
: library(nnet)
: library(lattice)
: library(ggplot2)
: library(caret)
: setwd("D:\\")
: Stock<-read.csv("real.csv",header=T)
: N<-nrow(Stock)
: set.seed(123)
: ind1<-sample(N,round(N*0.7))
: Train<-Stock[ind1,-1]
: Test<-Stock[-ind1,-1]
: st.net<-stock~usd.z+coffee.z+rice.z+oil.z+wheat.z+djopen.z+cu.z+corn.z
: model <- train(formula =st.net,data = Train,method="neuralnet", tuneGrid
: =data.frame(layer1=2:4,layer2=0, layer3=0),learningrate = 0.1, threshold =
: 0.1,stepmax =10000)
: https://imgur.com/rm3gifL
: [关键字]:
:
: 选择性,也许未来有用
:
我用你的资料直接照你的程式码下去测试基本上没问题
不过st.net先as.formula
train函数里面的摆的参数自己看一下套件文件再确定一下
不过我执行起来没什麽问题 我测试时设了两层神经层
st.net <- as.formula('stock ~
usd.z+coffee.z+rice.z+oil.z+wheat.z+dj.z+cu.z+corn.z')
modelst <- train(form = st.net,
data = traindata_real,
method = "neuralnet",
tuneGrid = expand.grid(.layer1 = c(2:4),
.layer2 = c(1:4),
.layer3 = c(0)),
learningrate = 0.01)
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.34.124.238
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1506869664.A.239.html
※ 编辑: KKbiger (1.34.124.238), 10/01/2017 23:19:41