简单线性回归
import pandas as pd
from collections import OrderedDict
import matplotlib.pyplot as plt
import matplotlib
准备数据集
'''准备数据集'''
examDict={
'学习时间':[0.50,0.75,1.00,1.25,1.50,1.75,1.75,2.00,2.25,
2.50,2.75,3.00,3.25,3.50,4.00,4.25,4.50,4.75,5.00,5.50],
'分数': [10, 22, 13, 43, 20, 22, 33, 50, 62,
48, 55, 75, 62, 73, 81, 76, 64, 82, 90, 93]
}
examOrderDict=OrderedDict(examDict)
examDf=pd.DataFrame(examOrderDict)
examDf.head()
|
学习时间 |
分数 |
0 |
0.50 |
10 |
1 |
0.75 |
22 |
2 |
1.00 |
13 |
3 |
1.25 |
43 |
4 |
1.50 |
20 |
提取特征和标签数据
'''提取特征和标签数据'''
examX=examDf['学习时间']
examY=examDf