Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ---
- ```{r setup, include=FALSE}
- knitr::opts_chunk$set(echo = TRUE)
- set.seed(5678)
- ```
- ## R Markdown
- This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
- When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
- ```{r}
- library(neuralnet)
- setwd("C:\\Chapter 06")
- myvalues <- read.csv("insurance.csv")
- hist(myvalues$expenses, 100) # Example: 100 breaks, but you can specify them at will
- pairs(~age+bmi+children+expenses,data=myvalues,
- main="Simple Scatterplot Matrix")
- nums <- sapply(myvalues, is.numeric)
- head(nums)
- filtered <- subset( myvalues, select = -c(sex, smoker, region ) )
- filtered
- maxs <- apply(filtered, 2, max)
- mins <- apply(filtered, 2, min)
- scaled <- as.data.frame(scale(filtered, center = mins, scale = maxs - mins))
- train_ <- scaled[index,]
- test_ <- scaled[-index,]
- n <- names(train_)
- nn <- neuralnet(expenses ~ age + bmi + children ,data=train_,hidden=1)
- plot(nn, rep ="best")
- net.result <- neuralnet::compute(
- nn, train_[,c("age",
- "bmi", "children")])
- net.result
- nn5 <- neuralnet(expenses ~ age + bmi + children ,data=train_,hidden=5)
- plot(nn5, rep ="best")
- net.result <- neuralnet::compute(
- nn5, train_[,c("age",
- "bmi", "children")])
- net.result
- ```
- ```{r cars}
- summary(cars)
- ```
- ## Including Plots
- You can also embed plots, for example:
- ```{r pressure, echo=FALSE}
- plot(pressure)
- ```
- Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement