Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plot neural net in rmarkdown

I am using the neuralnet package, to train a neural network. I am using rmarkdown html format, but at the moment of printing the plot is not displayed.

---
title: "neuralnet"
author: "RED"
date: "`r Sys.Date()`"
output: 
  html_document: 
    toc: yes
---

```{r}
library(neuralnet)
data(infert, package="datasets")
net.infert <- neuralnet(case~parity+induced+spontaneous, infert, 
                    err.fct="ce", linear.output=FALSE, likelihood=TRUE)
```

```{r}
plot(net.infert)
```

Any idea how to fix this.

like image 679
Rafael Díaz Avatar asked Dec 21 '25 03:12

Rafael Díaz


1 Answers

Add rep="best" to the plot command. If you don't, plot.nn plots each training epoch by constantly opening new graphics devices.

---
title: "neuralnet"
author: "RED"
date: "`r Sys.Date()`"
output: 
  html_document: 
    toc: yes
---

```{r}
library(neuralnet)
data(infert, package="datasets")
net.infert <- neuralnet(case~parity+induced+spontaneous, infert, 
                    err.fct="ce", linear.output=FALSE, likelihood=TRUE)
```

```{r}
plot(net.infert, rep="best")
```
like image 97
d125q Avatar answered Dec 23 '25 20:12

d125q



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!