Machine Learning - linear regression (based on the R language)

basic concept

Linear method, a relationship between the analog or more independent variables and the dependent variables. Argument is the input value model, the model dependent variables based on the output value of the argument.

The dependent variable is the result of independent variables and the linear superposition.

 

Logic behind the linear regression model - Least Squares method to calculate the linear coefficients

How to understand the least squares method?

Its main idea is to solve for the unknown parameters so that the difference between the theoretical and observed values ​​(i.e., error, or residual) and to minimize the square. Here the model is the theoretical value, point observations. Fitting target makes infinitely close to the target object.

A linear regression and multiple linear regression

Only one argument when called linear regression, since there are multiple variables when called multiple linear regression.

 

R language

bike.data <- read.csv("Shared Bike Sample Data - ML.csv")

lm (formula = Score + ~ + age groups Town, data = bike.data)

 summary(lm_fit)

The above variables missing Chaoyang District, the lack of control group. The reason is composed of all categorical variables dummy variables , there is a reference system does not appear as a linear regression results.

 

Supplementary Material - dummy

Dummy variable, the variable value of 0 or 1, it is converted to numerical variables categorical variables, and thus may be input to a linear regression model. Before input model converts a categorical variable for multiple dummy variables.

Categorical variables encountered in practice how to do?

For example:

 

Guess you like

Origin www.cnblogs.com/Grayling/p/10990151.html