Я получил исключение java .lang.NumberFormatException: для входной строки: "5.1" при чтении CSV - PullRequest
0 голосов
/ 12 апреля 2020
int numLinesToSkip = 0;
        char delimiter = ',';
        RecordReader recordReader = new CSVRecordReader(numLinesToSkip,delimiter);
//        recordReader.initialize(new FileSplit(new File(DownloaderUtility.IRISDATA.Download(),"iris.txt")));
        recordReader.initialize(new FileSplit(
                new File("iris.csv")
        ));
        //Second: the RecordReaderDataSetIterator handles conversion to DataSet objects, ready for use in neural network
        int labelIndex = 4;     //5 values in each row of the iris.txt CSV: 4 input features followed by an integer label (class) index. Labels are the 5th value (index 4) in each row
        int numClasses = 3;     //3 classes (types of iris flowers) in the iris data set. Classes have integer values 0, 1 or 2
        int batchSize = 150;    //Iris data set: 150 examples total. We are loading all of them into one DataSet (not recommended for large data sets)

        DataSetIterator iterator = new RecordReaderDataSetIterator(recordReader,batchSize,labelIndex,numClasses);
        DataSet allData = iterator.next();

Я хочу прочитать мой CSV, но он говорит, что 5.1, который является первым значением, является String.

1 Ответ

0 голосов
/ 30 апреля 2020

Проблема заключалась в том, что я не пропускал первый ряд набора данных.

...