Update Day2_Simple_Linear_Regression.md
This commit is contained in:
@ -2,11 +2,11 @@
|
||||
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/Avik-Jain/100-Days-Of-ML-Code/blob/master/Info-graphs/Day%202.jpg">
|
||||
<img src="https://github.com/wengJJ/100-Days-Of-ML-Code/blob/master/Info-graphs/Day%202.jpg">
|
||||
</p>
|
||||
|
||||
|
||||
# Step 1: Data Preprocessing
|
||||
# 第一步:数据预处理
|
||||
```python
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
@ -20,24 +20,24 @@ from sklearn.cross_validation import train_test_split
|
||||
X_train, X_test, Y_train, Y_test = train_test_split( X, Y, test_size = 1/4, random_state = 0)
|
||||
```
|
||||
|
||||
# Step 2: Fitting Simple Linear Regression Model to the training set
|
||||
# 第二步:训练集使用简单线性模型来训练
|
||||
```python
|
||||
from sklearn.linear_model import LinearRegression
|
||||
regressor = LinearRegression()
|
||||
regressor = regressor.fit(X_train, Y_train)
|
||||
```
|
||||
# Step 3: Predecting the Result
|
||||
# 第三步:预测结果
|
||||
```python
|
||||
Y_pred = regressor.predict(X_test)
|
||||
```
|
||||
|
||||
# Step 4: Visualization
|
||||
## Visualising the Training results
|
||||
# 第四步:可视化
|
||||
## 训练集结果可视化
|
||||
```python
|
||||
plt.scatter(X_train , Y_train, color = 'red')
|
||||
plt.plot(X_train , regressor.predict(X_train), color ='blue')
|
||||
```
|
||||
## Visualizing the test results
|
||||
## 测试集结果可视化
|
||||
```python
|
||||
plt.scatter(X_test , Y_test, color = 'red')
|
||||
plt.plot(X_test , regressor.predict(X_test), color ='blue')
|
||||
|
||||
Reference in New Issue
Block a user