import matplotlib.pyplot as plt
import pandas as pd
from collections import OrderedDict
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
examDict = {'学习时间':[0.5,0.75,1,1.25,1.5,1.75,1.75,2,2.25,2.5,2.75,3,
3.25,3.5,4,4.25,4.5,4.75,5,5.0],
'分数':[10,22,13,43,20,22,33,50,62,48,55,75,62,
73,81,76,64,82,90,93]
}
examOrderedDict = OrderedDict(examDict)
examDf = pd.DataFrame(examOrderedDict)
# examDf.head()
exam_X = examDf.loc[:,'学习时间']
exam_y = examDf.loc[:,'分数']
plt.scatter(exam_X,exam_y,color='b',label='exam data')
plt.legend(loc=2)
plt.xlabel('Hours')
plt.ylabel('Score')
plt.show()