linear_regression

package
v0.0.0-...-90b3c1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 12 Imported by: 0

README

Profiling the data

see that not all of our variables are normally distributed (that is, they are in a bell shape). The sales might be somewhat bell-shaped, but the others do not look to be normal.

Choosing our independent variable

Visually exploring the correlation between the dependent variable and all of the choices that you have for independent variables.

both Radio and TV appear to be somewhat linearly correlated with Sales. The linear relationship with TV seems most obvious

sales = m*TV + b

Train the model

Predicted = 7.0688 + TV*0.0489

Visualize regression line

Multiple regression

Sales = m1 * TV + m2 * Radio + b

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataSummary

func DataSummary(b io.Reader)

DataSummary prints summary statistics of data 1) Profiling the data

func PlotHistogram

func PlotHistogram(b io.Reader)

PlotHistogram plots histogram of data 1) Profiling the data

Example
PlotHistogram(data.GetAdvertisingCSVData())

func PlotRegressionLine

func PlotRegressionLine(b io.Reader)

func PlotScatter

func PlotScatter(b io.Reader)
Example
PlotScatter(data.GetAdvertisingCSVData())

func TrainModel

func TrainModel(b io.Reader)
Example
// The mean sales value was 14.02 and the standard deviation was 5.21.
// Thus, our MAE is less than the standard deviations of our sales values
// and is about 20% of the mean value, and our model has some predictive power.
TrainModel(data.GetAdvertisingCSVData())
Output:

Regression Formula:
Predicted = 7.0688 + TV*0.0489

MAE = 3.01

func TrainModelMultipleIndependentVariable

func TrainModelMultipleIndependentVariable(b io.Reader)
Example
// Our new multiple regression model has improved our MAE!
// Now we are definitely in pretty good shape to predict Sales based on our advertising spends
TrainModelMultipleIndependentVariable(data.GetAdvertisingCSVData())
Output:

Regression Formula:
Predicted = 2.9318 + TV*0.0473 + Radio*0.1794
MAE = 1.26

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL