Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Last active February 22, 2022 15:40
Show Gist options
  • Save MJacobs1985/41078449c15379831073e2e30b69011d to your computer and use it in GitHub Desktop.
Save MJacobs1985/41078449c15379831073e2e30b69011d to your computer and use it in GitHub Desktop.
#Bayesian Regularization for Feed-Forward Neural Networks
training_comp<-training%>%na.omit()
neurons=2
p=length(names(training_comp))-1
n=dim(training_comp)[1]
npar=neurons*(1+1+p)+1
brnngrid<-initnw(neurons,p,n,npar)
brnn1 <- train(rochefant~. - consumer, data = training_comp,
method = "brnn",
trControl = tr)
brnn1 <- train(rochefant~.-customer, data = training_comp,
method = "brnn",
trControl = tr)
testing_comp<-testing%>%na.omit()
testing_comp$pred<-predict(brnn1, testing)
ggplot(testing_comp, aes(rochefant,pred,
colour=as.factor(slaughtermonth))) +
geom_point(alpha=0.3, size=1) +
geom_smooth(method=lm, se=FALSE, linetype="dashed", size=1)+
geom_abline(slope=1, linetype="dashed") + theme_bw() +
facet_wrap(~slaughteryear)+theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment