package libsvm
Type Members
- class LibSVMDataSource extends AnyRef
libsvmpackage implements Spark SQL data source API for loading LIBSVM data asDataFrame.libsvmpackage implements Spark SQL data source API for loading LIBSVM data asDataFrame. The loadedDataFramehas two columns:labelcontaining labels stored as doubles andfeaturescontaining feature vectors stored asVectors.To use LIBSVM data source, you need to set "libsvm" as the format in
DataFrameReaderand optionally specify options, for example:// Scala val df = spark.read.format("libsvm") .option("numFeatures", "780") .load("data/mllib/sample_libsvm_data.txt") // Java Dataset<Row> df = spark.read().format("libsvm") .option("numFeatures, "780") .load("data/mllib/sample_libsvm_data.txt");
LIBSVM data source supports the following options:
- "numFeatures": number of features. If unspecified or nonpositive, the number of features will be determined automatically at the cost of one additional pass. This is also useful when the dataset is already split into multiple files and you want to load them separately, because some features may not present in certain files, which leads to inconsistent feature dimensions.
- "vectorType": feature vector type, "sparse" (default) or "dense".
- Note
This class is public for documentation purpose. Please don't use this class directly. Rather, use the data source API as illustrated above.
- See also