3

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.

Rafael Díaz
  • 2,134
  • 2
  • 16
  • 32
  • 1
    Possible duplicate of [knitr and plotting neural networks](https://stackoverflow.com/questions/43795530/knitr-and-plotting-neural-networks) – Werner Nov 20 '18 at 00:58

1 Answers1

5

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")
```
d125q
  • 1,666
  • 12
  • 18