报错:AttributeError: '_csv.reader' object has no attribute 'next'
原因:python版本问题
解决:将headers = reader.next()改为headers = next(reader)
报错:_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
原因:csv文件并非二进制文件, 只是一个文本文件
解决:将allElectronicsData = open(r'F:/txt/AllElectronics.csv', 'rb')改成allElectronicsData = open(r'F:/txt/AllElectronics.csv', 'rt')
报错:ValueError: Expected 2D array, got 1D array instead
原因:数据维度不对,将其通过reshape进行转化
解决:将predictedY = clf.predict(newRowX)改成predictedY = clf.predict(newRowX.reshape(1,-1))