3
votes

In scikit-learn, two functions are provided to load and dump files in SVM^light format:

sklearn.datasets.load_svmlight_file and sklearn.datasets.dump_svmlight_file

The documentation shows (and the function supports) that load_svmlight_file can load multi-label data, that is where the target categories are separated by a comma, instead of there being a single category as the target. However, the dump_svmlight_file doesn't seem to support this.

Am I reading things wrong, or does the dump_svmlight_file for some reason just not support this? Its not even possible to 'trick it' by passing a y-vector with string-based target values, because the file writer requires a float for the value. The dump file code can be found at https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/datasets/svmlight_format.py from line 230 to 262.

1
It sounds like a bug. Could you please edit your question to add a small 10 liner max snippet that exhibits the issue on some toy 3 lines svmlight files? Ideally that could be integrated as a non regression test in the sklearn test suite. - ogrisel
@ogrisel: not a bug, just not implemented (and not promised in the documentation either). - Fred Foo
Alright, I had misread the original question. - ogrisel

1 Answers

3
votes

You're right, dump_svmlight_file does not at present support multi-label tasks. That's an omission; you can file a bug report for it, although a good patch (pull request) would lead to quicker action.

(Signed, one of the authors of that module.)