Linear regression
Linear Regression is a linear model that is used to determine and predict numerical values. Linear regression is one of the most basic and important starting points in understanding linear models and predictive analytics. For this recipe, we will use Julia's GLM.jl
package.
Getting ready
To get started with this recipe, you have to add the GLM.jl
Julia package. It can be added and imported in the REPL using the Pkg.add(" ")
command just like we added other packages before. This can be done as follows:
Pkg.add("GLM")
Now, import the package using the using " "
command. The DataFrames
package is also required to be imported. This can be done as follows:
using GLM using DataFrames
How to do it...
Here, we will attempt to perform a simple linear regression on two basic arrays, which we have generated on-the-fly. Let's call the two array
A
andB
and then, create a dataframe containing them. This can be done as follows:df = DataFrame(A = [3, 6, 9], B = [34, 56, 67])
Now the...