numpy.loadtxt('iris.data.txt', delimiter = ',', converters ={4:read
data in iris.data.txt file
such as:
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
######################################################################
import numpy as np
import matplotlib.pyplot as plt
label_set = (
b'Iris-setosa',
b'Iris-versicolor',
b'Iris-virginica',
) #tuple
def read_label2(label):
return label_set.index(label)
#The last column that gives the label of each point is a string that can take three possible values—Iris-virginica, Iris-versicolor, and Iris-Vertosa.
data = np.loadtxt('iris.data.txt', delimiter = ',', converters ={4:read_label2})
color_set = ('.00', '.50', '.75')
color_list = [color_set[int(label)] for label in data[:,4]
]
plt.scatter(data[:,0], data[:,1], color=color_list)
plt.show()
data[:4]
output:
array([[5.1, 3.5, 1.4, 0.2, 0. ], [4.9, 3. , 1.4, 0.2, 0. ], [4.7, 3.2, 1.3, 0.2, 1. ], [4.6, 3.1, 1.5, 0.2, 1. ]])
相关知识
鸢尾花数据读取的总结
鸢尾花数据读取
SVM实现鸢尾花分类
用svm进行鸢尾花分类
逻辑回归分类、决策树分类、朴素贝叶斯分类及手写数字识别
机器学习项目实践——鸢尾花分类
附源码
作业5:SVM实现鸢尾花分类
用另一种方式解决WARNING: Retrying (Retry(total=4, connect
利用Numpy进行鸢尾花数据集分析
网址: numpy.loadtxt('iris.data.txt', delimiter = ',', converters ={4:read https://www.huajiangbk.com/newsview689399.html
上一篇: 大班美术美丽的蜡烛花教案反思 |
下一篇: 适合夏季播种的花卉种子有哪些 |
推荐分享

- 1君子兰什么品种最名贵 十大名 4012
- 2世界上最名贵的10种兰花图片 3364
- 3花圈挽联怎么写? 3286
- 4迷信说家里不能放假花 家里摆 1878
- 5香山红叶什么时候红 1493
- 6花的意思,花的解释,花的拼音 1210
- 7教师节送什么花最合适 1167
- 8勿忘我花图片 1103
- 9橄榄枝的象征意义 1093
- 10洛阳的市花 1039