Fork me on GitHub

This documentation is for scikit-learn version 0.15-gitOther versions

If you use the software, please consider citing scikit-learn.

sklearn.datasets.load_svmlight_files

sklearn.datasets.load_svmlight_files(files, n_features=None, dtype=<type 'numpy.float64'>, multilabel=False, zero_based='auto', query_id=False)

Load dataset from multiple files in SVMlight format

This function is equivalent to mapping load_svmlight_file over a list of files, except that the results are concatenated into a single, flat list and the samples vectors are constrained to all have the same number of features.

In case the file contains a pairwise preference constraint (known as “qid” in the svmlight format) these are ignored unless the query_id parameter is set to True. These pairwise preference constraints can be used to constraint the combination of samples when using pairwise loss functions (as is the case in some learning to rank problems) so that only pairs with the same query_id value are considered.

Parameters:

files : iterable over {str, file-like, int}

(Paths of) files to load. If a path ends in ”.gz” or ”.bz2”, it will be uncompressed on the fly. If an integer is passed, it is assumed to be a file descriptor. File-likes and file descriptors will not be closed by this function. File-like objects must be opened in binary mode.

n_features: int or None :

The number of features to use. If None, it will be inferred from the maximum column index occurring in any of the files.

This can be set to a higher value than the actual number of features in any of the input files, but setting it to a lower value will cause an exception to be raised.

multilabel: boolean, optional :

zero_based: boolean or “auto”, optional :

Whether column indices in f are zero-based (True) or one-based (False). If column indices are one-based, they are transformed to zero-based to match Python/NumPy conventions. If set to “auto”, a heuristic check is applied to determine this from the file contents. Both kinds of files occur “in the wild”, but they are unfortunately not self-identifying. Using “auto” or True should always be safe.

query_id: boolean, defaults to False :

If True, will return the query_id array for each file.

Returns:

[X1, y1, ..., Xn, yn] :

where each (Xi, yi) pair is the result from load_svmlight_file(files[i]). :

If query_id is set to True, this will return instead [X1, y1, q1, :

..., Xn, yn, qn] where (Xi, yi, qi) is the result from :

load_svmlight_file(files[i]) :