Day 2 Simple linear regression

Simple linear regression : predicting response of a single feature.

Task: an argument based on the predicted dependent variable is assumed that two variables are linearly related, to try to find a linear function can be used to accurately predict the response value X according to the characteristics or arguments Y.

Objective: to find the best fit line, (observed value Y minimizing the prediction error i value Y and the prediction model p length between), SUM {i.e., min (Y i -Y p ) 2 }

step:

A data preprocessing

  1, import required libraries

  2, introduced into the data set

  3, check for missing data and complement

  4, the data set is divided into training and test sets

  5, feature scaling

Second, training

  Use simple linear regression model to train the training set. Call sklearn.linear_model in LinearRegression to train a linear regression model. The method may LinearRegression fit into objects of LinearRegression

Line training.

Third, the forecast

  Predicting the response value using LinearRegression predict function.

Fourth, the results visualization

  The use matplotlib pyplot functions are identified by the prediction function and the data points plotted in different colors training set, the test set.

 

Guess you like

Origin www.cnblogs.com/rainton-z/p/11620273.html