Linear Regression
learning target
- Ownership in the implementation process of linear regression
- Application LinearRegression or SGDRegressor achieve regression prediction
- We know the assessment criteria and formulas regression algorithm
- Overfitting know the causes and solutions underfitting
- We know principle ridge regression and linear regression differences
- Application Ridge achieve regression prediction
- Application joblib achieve saving and loading models
2.2 linear regression api initial use
![Here Insert Picture Description](https://img-blog.csdnimg.cn/20200303220401235.png)
1 linear regression API
- sklearn.linear_model.LinearRegression()
- LinearRegression.coef_: regression coefficient
2 Examples
![[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-mtBiKTz6-1583244220720) (../ images /% E7% BA% BF% E6% 80% A7% E5 % 9B% 9E% E5% BD% 92api% E4% BD% BF% E7% 94% A8% E4% B8% BE% E4% BE% 8B.png)]](https://img-blog.csdnimg.cn/20200303220349248.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NDU2MDQ1,size_16,color_FFFFFF,t_70)
2.1 Analysis of step
- 1. Obtain data set
- 2. Basic data processing (omitted in this case)
- 3. The feature works (in this case omitted)
- 4. Machine Learning
- The model assessment (omitted in this case)
2.2 Code Process
from sklearn.linear_model import LinearRegression
x = [[80, 86],
[82, 80],
[85, 78],
[90, 90],
[86, 82],
[82, 90],
[78, 80],
[92, 94]]
y = [84.2, 80.6, 80.1, 90, 83.2, 87.6, 79.4, 93.4]
- Machine learning - training model
estimator = LinearRegression()
estimator.fit(x,y)
estimator.coef_
estimator.predict([[100, 80]])