在机器学习中遇到下面两个语句,想了半天,也看了一些其他博主文章后自己的总结:
featList = [example[i] for example in dataSet]
- 1
classList = [example[-1] for example in dataSet]
- 2
多方研究和询问,得到如下解释:
语句featList = [example[i] for example in dataSet]
作用为:
将dataSet中的数据先按行依次放入example中,然后取得example中的example[i]元素,放入列表featList中
语句classList = [example[-1] for example in dataSet]
作用为:
将dataSet中的数据先按行依次放入example中,然后取得example中的example[-1]元素,放入列表classList中
对数据的遍历一般都是按行,这是取其列的方法!!