cjlin1/liblinear

`train` fails to read input file

christoph-conrads opened this issue · 3 comments

According to the LIBLINEAR website, liblinear and libsvm use the same input format. On my computer, train signals an error when it reads an input file that is successfully parsed by libsvm. I traced the different behavior to line 395 in train.c:

		inst_max_index = 0; // strtol gives 0 if wrong format

In libsvm, the same variable is initialized to -1 and changing inst_max_index allows train to read the file successfully, too.

It looks very likely from both issues you posted that your data set feature enumeration starts with 0, while libsvm and liblinear both require it starts from 1. The counter 0 in libsvm is allowed for precomputed kernel only.

You are right leepei and here is the relevant line in the libsvm README:

The pair <index>:<value> gives a feature
(attribute) value: <index> is an integer starting from 1 and <value>
is a real number.

@leepei Thank you for the quick response.