Neural networks as an extension of linear regression

One of the simplest and oldest prediction models is regression. It predicts a continuous value (that is, a number) based on another value. The linear regression function is:


Where y is the value you want to predict and x is your input variable. The linear regression coefficients (or parameters) are m (the slope of the line) and b (the intercept). The following R code creates a line with the y= 1.4x -2 function and plots it:

set.seed(42)m <- 1.4b <- -1.2x <- 0:9jitter<-0.6xline <- xy <- m*x+bx <- x+rnorm(10)*jittertitle <- paste("y = ",m,"x ",b,sep="")plot(xline,y,type="l",lty=2,col="red",main=title,xlim=c(0,max(y)),ylim=c(0,max(y)))points(x[seq(1,10,2)],y[seq(1,10,2)],pch=1)points(x[seq(2,11,2)],y[seq(2,11,2)],pch=4) ...

Get R Deep Learning Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.