public class MLUtils extends Object
This object contains convenience functions for machine learning tasks:
- readLibSVM:
Reads a libSVM/SVMLight input file and returns a data set of LabeledVector
.
The file format is specified [http://svmlight.joachims.org/ here].
- writeLibSVM:
Writes a data set of LabeledVector
in libSVM/SVMLight format to disk. THe file format
is specified [http://svmlight.joachims.org/ here].
Constructor and Description |
---|
MLUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
DIMENSION() |
static DataSet<LabeledVector> |
readLibSVM(ExecutionEnvironment env,
String filePath)
Reads a file in libSVM/SVMLight format and converts the data into a data set of
LabeledVector . |
static DataSink<String> |
writeLibSVM(String filePath,
DataSet<LabeledVector> labeledVectors)
Writes a
DataSet of LabeledVector to a file using the libSVM/SVMLight format. |
public static String DIMENSION()
public static DataSet<LabeledVector> readLibSVM(ExecutionEnvironment env, String filePath)
LabeledVector
. The dimension of the LabeledVector
is determined automatically.
Since the libSVM/SVMLight format stores a vector in its sparse form, the LabeledVector
will also be instantiated with a SparseVector
.
env
- executionEnvironment ExecutionEnvironment
filePath
- Path to the input fileDataSet
of LabeledVector
containing the information of the libSVM/SVMLight
filepublic static DataSink<String> writeLibSVM(String filePath, DataSet<LabeledVector> labeledVectors)
DataSet
of LabeledVector
to a file using the libSVM/SVMLight format.
filePath
- Path to output filelabeledVectors
- DataSet
of LabeledVector
to write to diskCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.