public class LIBSVMLoader extends Object
DataSet
. LIVSM files do not indicate
whether or not the target variable is supposed to be numerical or
categorical, so two different loading methods are provided. For a LIBSVM file
to be loaded correctly, it must match the LIBSVM spec without extensions.
vectorLength
parameter to specify
the length before hand.Modifier and Type | Method and Description |
---|---|
static ClassificationDataSet |
loadC(File file)
Loads a new classification data set from a LIBSVM file, assuming the
label is a nominal target value
|
static ClassificationDataSet |
loadC(File file,
double sparseRatio)
Loads a new classification data set from a LIBSVM file, assuming the
label is a nominal target value
|
static ClassificationDataSet |
loadC(File file,
double sparseRatio,
int vectorLength)
Loads a new classification data set from a LIBSVM file, assuming the
label is a nominal target value
|
static ClassificationDataSet |
loadC(InputStreamReader isr,
double sparseRatio)
Loads a new classification data set from a LIBSVM file, assuming the
label is a nominal target value
|
static ClassificationDataSet |
loadC(Reader reader,
double sparseRatio,
int vectorLength)
Loads a new classification data set from a LIBSVM file, assuming the
label is a nominal target value
|
static RegressionDataSet |
loadR(File file)
Loads a new regression data set from a LIBSVM file, assuming the label is
a numeric target value to predict
|
static RegressionDataSet |
loadR(File file,
double sparseRatio)
Loads a new regression data set from a LIBSVM file, assuming the label is
a numeric target value to predict
|
static RegressionDataSet |
loadR(File file,
double sparseRatio,
int vectorLength)
Loads a new regression data set from a LIBSVM file, assuming the label is
a numeric target value to predict
|
static RegressionDataSet |
loadR(InputStreamReader isr,
double sparseRatio)
Loads a new regression data set from a LIBSVM file, assuming the label is
a numeric target value to predict
|
static RegressionDataSet |
loadR(Reader reader,
double sparseRatio,
int vectorLength)
Loads a new regression data set from a LIBSVM file, assuming the label is
a numeric target value to predict.
|
static void |
write(ClassificationDataSet data,
OutputStream os)
Writes out the given classification data set as a LIBSVM data file
|
static void |
write(RegressionDataSet data,
OutputStream os)
Writes out the given regression data set as a LIBSVM data file
|
public static RegressionDataSet loadR(File file) throws FileNotFoundException, IOException
file
- the file to loadFileNotFoundException
- if the file was not foundIOException
- if an error occurred reading the input streampublic static RegressionDataSet loadR(File file, double sparseRatio) throws FileNotFoundException, IOException
file
- the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparseFileNotFoundException
- if the file was not foundIOException
- if an error occurred reading the input streampublic static RegressionDataSet loadR(File file, double sparseRatio, int vectorLength) throws FileNotFoundException, IOException
file
- the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparsevectorLength
- the pre-determined length of each vector. If given a
negative value, the largest non-zero index observed in the data will be
used as the length.FileNotFoundException
- if the file was not foundIOException
- if an error occurred reading the input streampublic static RegressionDataSet loadR(InputStreamReader isr, double sparseRatio) throws IOException
isr
- the input stream for the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparseIOException
- if an error occurred reading the input streampublic static RegressionDataSet loadR(Reader reader, double sparseRatio, int vectorLength) throws IOException
reader
- the reader for the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparsevectorLength
- the pre-determined length of each vector. If given a
negative value, the largest non-zero index observed in the data will be
used as the length.IOException
public static ClassificationDataSet loadC(File file) throws FileNotFoundException, IOException
file
- the file to loadFileNotFoundException
- if the file was not foundIOException
- if an error occurred reading the input streampublic static ClassificationDataSet loadC(File file, double sparseRatio) throws FileNotFoundException, IOException
file
- the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparseFileNotFoundException
- if the file was not foundIOException
- if an error occurred reading the input streampublic static ClassificationDataSet loadC(File file, double sparseRatio, int vectorLength) throws FileNotFoundException, IOException
file
- the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparsevectorLength
- the pre-determined length of each vector. If given a
negative value, the largest non-zero index observed in the data will be
used as the length.FileNotFoundException
- if the file was not foundIOException
- if an error occurred reading the input streampublic static ClassificationDataSet loadC(InputStreamReader isr, double sparseRatio) throws IOException
isr
- the input stream for the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparseIOException
- if an error occurred reading the input streampublic static ClassificationDataSet loadC(Reader reader, double sparseRatio, int vectorLength) throws IOException
reader
- the input stream for the file to loadsparseRatio
- the fraction of non zero values to qualify a data
point as sparsevectorLength
- the pre-determined length of each vector. If given a
negative value, the largest non-zero index observed in the data will be
used as the length.IOException
- if an error occurred reading the input streampublic static void write(ClassificationDataSet data, OutputStream os)
data
- the data set to write to a fileos
- the output stream to write to. The stream will not be closed or
flushed by this methodpublic static void write(RegressionDataSet data, OutputStream os)
data
- the data set to write to a fileos
- the output stream to write to. The stream will not be closed or
flushed by this methodCopyright © 2017. All rights reserved.