Data sources
In this section, we introduce how to use data source in ML to load data. Besides some general data sources such as Parquet, CSV, JSON and JDBC, we also provide some specific data sources for ML.
Table of Contents
Image data source
This image data source is used to load image files from a directory, it can load compressed image (jpeg, png, etc.) into raw image representation via ImageIO
in Java library.
The loaded DataFrame has one StructType
column: “image”, containing image data stored as image schema.
The schema of the image
column is:
- origin:
StringType
(represents the file path of the image) - height:
IntegerType
(height of the image) - width:
IntegerType
(width of the image) - nChannels:
IntegerType
(number of image channels) - mode:
IntegerType
(OpenCV-compatible type) - data:
BinaryType
(Image bytes in OpenCV-compatible order: row-wise BGR in most cases)
ImageDataSource
implements a Spark SQL data source API for loading image data as a DataFrame.
ImageDataSource
implements Spark SQL data source API for loading image data as a DataFrame.
In PySpark we provide Spark SQL data source API for loading image data as a DataFrame.
In SparkR we provide Spark SQL data source API for loading image data as a DataFrame.
LIBSVM data source
This LIBSVM
data source is used to load ‘libsvm’ type files from a directory.
The loaded DataFrame has two columns: label containing labels stored as doubles and features containing feature vectors stored as Vectors.
The schemas of the columns are:
- label:
DoubleType
(represents the instance label) - features:
VectorUDT
(represents the feature vector)
LibSVMDataSource
implements a Spark SQL data source API for loading LIBSVM
data as a DataFrame.
LibSVMDataSource
implements Spark SQL data source API for loading LIBSVM
data as a DataFrame.
In PySpark we provide Spark SQL data source API for loading LIBSVM
data as a DataFrame.
In SparkR we provide Spark SQL data source API for loading LIBSVM
data as a DataFrame.