赞
踩
import pandas as pd
# 导入orderedDict,为了建立有序的字典
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)
# 建立DataFrame格式数据
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。