它不太有效,因为mlpMLFit
在您的示例中是train
插入符号的对象。我认为一个好的和安全的方法可能是用你最好的调整参数再次拟合模型,例如:
library(caret)
library(mlbench)
data(BostonHousing)
ctrl <- trainControl(method="cv", number=4)
TG = expand.grid(layer1=2:4,layer2=2:4,layer3=2:4)
mlpMLFit <- train(medv ~ ., data = BostonHousing, method = "mlpML", trControl = ctrl, preProcess = c("center", "scale"), tuneGrid=TG)
我们mlp()
用来改装模型:
library(RSNNS)
library(devtools)
source_url('https://gist.githubusercontent.com/fawda123/7471137/raw/466c1474d0a505ff044412703516c34f1a4684a5/nnet_plot_update.r')
fit = mlp(x=model.matrix(medv ~ .,data=BostonHousing),
y=BostonHousing$medv,size=as.numeric(mlpMLFit$bestTune))
您可以使用此处描述的绘图功能:
library(devtools)
source_url('https://gist.githubusercontent.com/fawda123/7471137/raw/466c1474d0a505ff044412703516c34f1a4684a5/nnet_plot_update.r')
plot.nnet(fit)