2020-12-01

大作业

本次练习使用 鸢尾属植物数据集 .\iris.data ,在这个数据集中,包括了三类不同的鸢尾属植物:
Iris Setosa,Iris Versicolour,Iris Virginica。每类收集了50个样本,因此这个数据集一共包含了
150个样本。
sepallength:萼片长度
sepalwidth:萼片宽度
petallength:花瓣长度
petalwidth:花瓣宽度
以上四个特征的单位都是厘米(cm)。
sepallength sepalwidth petallength petalwidth species
0 5.1 3.5 1.4 0.2 Iris‐setosa
1 4.9 3.0 1.4 0.2 Iris‐setosa
2 4.7 3.2 1.3 0.2 Iris‐setosa
3 4.6 3.1 1.5 0.2 Iris‐setosa
4 5.0 3.6 1.4 0.2 Iris‐setosa
导入鸢尾属植物数据集,保持文本不变。
【知识点:输入和输出】
如何导入存在数字和文本的数据集?
【答案】
import numpy as np
outfile = r’.\iris.data’
iris_data = np.loadtxt(outfile, dtype=object, delimiter=’,’, skiprows=1)
print(iris_data[0:10])
求出鸢尾属植物萼片长度的平均值、中位数和标准差(第1列,sepallength)
【知识点:统计相关】
如何计算numpy数组的均值,中位数,标准差?
【答案】
import numpy as np
outfile = r’.\iris.data’
sepalLength = np.loadtxt(outfile, dtype=float, delimiter=’,’, skiprows=1, usecols=[0])
print(sepalLength[0:10])
创建一种标准化形式的鸢尾属植物萼片长度,其值正好介于0和1之间,这样最小值为0,最大值为
1(第1列,sepallength)。
【知识点:统计相关】
如何标准化数组?
【答案】
import numpy as np
outfile = r’.\iris.data’
sepalLength = np.loadtxt(outfile, dtype=float, delimiter=’,’, skiprows=1, usecols=[0])

上一篇:MySQL的SQL语句 - 数据操作语句(12)- SELECT 语句(2)


下一篇:遥测终端_水文遥测终端_遥测终端RTU