machinelearninginaction
machinelearninginaction copied to clipboard
ch02
line 53, in file2matrix classLabelVector.append(int(listFromLine[-1])) ValueError: invalid literal for int() with base 10: 'largeDoses'
the data in datingTestSet.txt like this 40920 8.326976 0.953952 largeDoses the error is in kNN line 53 for the sorce code : classLabelVector.append(int(listFromLine[-1])) ; that largeDoses can't cast to int
hello @kgdngitfk , use: "data/2.KNN/datingTestSet2.txt" plz, do not use datingTestSet
;
the reason why you encount : ValueError: invalid literal for int() with base 10: 'largeDoses'
is because the last column of datingTestSet.txt is String, not Integer;
so use data/2.KNN/datingTestSet2.txt" plz