Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package apache
    Definition Classes
    org
  • package spark

    Core Spark functionality.

    Core Spark functionality. org.apache.spark.SparkContext serves as the main entry point to Spark, while org.apache.spark.rdd.RDD is the data type representing a distributed collection, and provides most parallel operations.

    In addition, org.apache.spark.rdd.PairRDDFunctions contains operations available only on RDDs of key-value pairs, such as groupByKey and join; org.apache.spark.rdd.DoubleRDDFunctions contains operations available only on RDDs of Doubles; and org.apache.spark.rdd.SequenceFileRDDFunctions contains operations available on RDDs that can be saved as SequenceFiles. These operations are automatically available on any RDD of the right type (e.g. RDD[(Int, Int)] through implicit conversions.

    Java programmers should reference the org.apache.spark.api.java package for Spark programming APIs in Java.

    Classes and methods marked with Experimental are user-facing features which have not been officially adopted by the Spark project. These are subject to change or removal in minor releases.

    Classes and methods marked with Developer API are intended for advanced users want to extend Spark through lower level interfaces. These are subject to changes or removal in minor releases.

    Definition Classes
    apache
  • package api
    Definition Classes
    spark
  • package broadcast

    Spark's broadcast variables, used to broadcast immutable datasets to all nodes.

    Spark's broadcast variables, used to broadcast immutable datasets to all nodes.

    Definition Classes
    spark
  • package graphx

    ALPHA COMPONENT GraphX is a graph processing framework built on top of Spark.

    ALPHA COMPONENT GraphX is a graph processing framework built on top of Spark.

    Definition Classes
    spark
  • package input
    Definition Classes
    spark
  • package io

    IO codecs used for compression.

    IO codecs used for compression. See org.apache.spark.io.CompressionCodec.

    Definition Classes
    spark
  • package launcher
    Definition Classes
    spark
  • package mapred
    Definition Classes
    spark
  • package metrics
    Definition Classes
    spark
  • package ml

    DataFrame-based machine learning APIs to let users quickly assemble and configure practical machine learning pipelines.

    DataFrame-based machine learning APIs to let users quickly assemble and configure practical machine learning pipelines.

    Definition Classes
    spark
  • package attribute

    The ML pipeline API uses DataFrames as ML datasets.

    ML attributes

    The ML pipeline API uses DataFrames as ML datasets. Each dataset consists of typed columns, e.g., string, double, vector, etc. However, knowing only the column type may not be sufficient to handle the data properly. For instance, a double column with values 0.0, 1.0, 2.0, ... may represent some label indices, which cannot be treated as numeric values in ML algorithms, and, for another instance, we may want to know the names and types of features stored in a vector column. ML attributes are used to provide additional information to describe columns in a dataset.

    ML columns

    A column with ML attributes attached is called an ML column. The data in ML columns are stored as double values, i.e., an ML column is either a scalar column of double values or a vector column. Columns of other types must be encoded into ML columns using transformers. We use Attribute to describe a scalar ML column, and AttributeGroup to describe a vector ML column. ML attributes are stored in the metadata field of the column schema.

  • package classification
  • package clustering
  • package evaluation
  • package feature

    The ml.feature package provides common feature transformers that help convert raw data or features into more suitable forms for model fitting.

    Feature transformers

    The ml.feature package provides common feature transformers that help convert raw data or features into more suitable forms for model fitting. Most feature transformers are implemented as Transformers, which transform one DataFrame into another, e.g., HashingTF. Some feature transformers are implemented as Estimators, because the transformation requires some aggregated information of the dataset, e.g., document frequencies in IDF. For those feature transformers, calling Estimator.fit is required to obtain the model first, e.g., IDFModel, in order to apply transformation. The transformation is usually done by appending new columns to the input DataFrame, so all input columns are carried over.

    We try to make each transformer minimal, so it becomes flexible to assemble feature transformation pipelines. Pipeline can be used to chain feature transformers, and VectorAssembler can be used to combine multiple feature transformations, for example:

    import org.apache.spark.ml.feature._
    import org.apache.spark.ml.Pipeline
    
    // a DataFrame with three columns: id (integer), text (string), and rating (double).
    val df = spark.createDataFrame(Seq(
      (0, "Hi I heard about Spark", 3.0),
      (1, "I wish Java could use case classes", 4.0),
      (2, "Logistic regression models are neat", 4.0)
    )).toDF("id", "text", "rating")
    
    // define feature transformers
    val tok = new RegexTokenizer()
      .setInputCol("text")
      .setOutputCol("words")
    val sw = new StopWordsRemover()
      .setInputCol("words")
      .setOutputCol("filtered_words")
    val tf = new HashingTF()
      .setInputCol("filtered_words")
      .setOutputCol("tf")
      .setNumFeatures(10000)
    val idf = new IDF()
      .setInputCol("tf")
      .setOutputCol("tf_idf")
    val assembler = new VectorAssembler()
      .setInputCols(Array("tf_idf", "rating"))
      .setOutputCol("features")
    
    // assemble and fit the feature transformation pipeline
    val pipeline = new Pipeline()
      .setStages(Array(tok, sw, tf, idf, assembler))
    val model = pipeline.fit(df)
    
    // save transformed features with raw data
    model.transform(df)
      .select("id", "text", "rating", "features")
      .write.format("parquet").save("/output/path")

    Some feature transformers implemented in MLlib are inspired by those implemented in scikit-learn. The major difference is that most scikit-learn feature transformers operate eagerly on the entire input dataset, while MLlib's feature transformers operate lazily on individual columns, which is more efficient and flexible to handle large and complex datasets.

    See also

    scikit-learn.preprocessing

  • package fpm
  • package image
  • package linalg
  • package param
  • package recommendation
  • package regression
  • package source
  • package stat
  • package tree
  • package tuning
  • package util
  • Estimator
  • FitEnd
  • FitStart
  • LoadInstanceEnd
  • LoadInstanceStart
  • MLEvent
  • Model
  • Pipeline
  • PipelineModel
  • PipelineStage
  • PredictionModel
  • Predictor
  • SaveInstanceEnd
  • SaveInstanceStart
  • TransformEnd
  • TransformStart
  • Transformer
  • UnaryTransformer
  • functions
  • package mllib

    RDD-based machine learning APIs (in maintenance mode).

    RDD-based machine learning APIs (in maintenance mode).

    The spark.mllib package is in maintenance mode as of the Spark 2.0.0 release to encourage migration to the DataFrame-based APIs under the org.apache.spark.ml package. While in maintenance mode,

    • no new features in the RDD-based spark.mllib package will be accepted, unless they block implementing new features in the DataFrame-based spark.ml package;
    • bug fixes in the RDD-based APIs will still be accepted.

    The developers will continue adding more features to the DataFrame-based APIs in the 2.x series to reach feature parity with the RDD-based APIs. And once we reach feature parity, this package will be deprecated.

    Definition Classes
    spark
    See also

    SPARK-4591 to track the progress of feature parity

  • package partial

    Support for approximate results.

    Support for approximate results. This provides convenient api and also implementation for approximate calculation.

    Definition Classes
    spark
    See also

    org.apache.spark.rdd.RDD.countApprox

  • package paths
    Definition Classes
    spark
  • package rdd

    Provides several RDD implementations.

    Provides several RDD implementations. See org.apache.spark.rdd.RDD.

    Definition Classes
    spark
  • package resource
    Definition Classes
    spark
  • package scheduler

    Spark's scheduling components.

    Spark's scheduling components. This includes the org.apache.spark.scheduler.DAGScheduler and lower level org.apache.spark.scheduler.TaskScheduler.

    Definition Classes
    spark
  • package security
    Definition Classes
    spark
  • package serializer

    Pluggable serializers for RDD and shuffle data.

    Pluggable serializers for RDD and shuffle data.

    Definition Classes
    spark
    See also

    org.apache.spark.serializer.Serializer

  • package shuffle
    Definition Classes
    spark
  • package sql

    Allows the execution of relational queries, including those expressed in SQL using Spark.

    Allows the execution of relational queries, including those expressed in SQL using Spark.

    Definition Classes
    spark
  • package status
    Definition Classes
    spark
  • package storage
    Definition Classes
    spark
  • package streaming

    Spark Streaming functionality.

    Spark Streaming functionality. org.apache.spark.streaming.StreamingContext serves as the main entry point to Spark Streaming, while org.apache.spark.streaming.dstream.DStream is the data type representing a continuous sequence of RDDs, representing a continuous stream of data.

    In addition, org.apache.spark.streaming.dstream.PairDStreamFunctions contains operations available only on DStreams of key-value pairs, such as groupByKey and reduceByKey. These operations are automatically available on any DStream of the right type (e.g. DStream[(Int, Int)] through implicit conversions.

    For the Java API of Spark Streaming, take a look at the org.apache.spark.streaming.api.java.JavaStreamingContext which serves as the entry point, and the org.apache.spark.streaming.api.java.JavaDStream and the org.apache.spark.streaming.api.java.JavaPairDStream which have the DStream functionality.

    Definition Classes
    spark
  • package types
    Definition Classes
    spark
  • package ui
    Definition Classes
    spark
  • package unsafe
    Definition Classes
    spark
  • package util

    Spark utilities.

    Spark utilities.

    Definition Classes
    spark

package ml

DataFrame-based machine learning APIs to let users quickly assemble and configure practical machine learning pipelines.

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ml
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package attribute

    The ML pipeline API uses DataFrames as ML datasets.

    ML attributes

    The ML pipeline API uses DataFrames as ML datasets. Each dataset consists of typed columns, e.g., string, double, vector, etc. However, knowing only the column type may not be sufficient to handle the data properly. For instance, a double column with values 0.0, 1.0, 2.0, ... may represent some label indices, which cannot be treated as numeric values in ML algorithms, and, for another instance, we may want to know the names and types of features stored in a vector column. ML attributes are used to provide additional information to describe columns in a dataset.

    ML columns

    A column with ML attributes attached is called an ML column. The data in ML columns are stored as double values, i.e., an ML column is either a scalar column of double values or a vector column. Columns of other types must be encoded into ML columns using transformers. We use Attribute to describe a scalar ML column, and AttributeGroup to describe a vector ML column. ML attributes are stored in the metadata field of the column schema.

  2. package classification
  3. package clustering
  4. package evaluation
  5. package feature

    The ml.feature package provides common feature transformers that help convert raw data or features into more suitable forms for model fitting.

    Feature transformers

    The ml.feature package provides common feature transformers that help convert raw data or features into more suitable forms for model fitting. Most feature transformers are implemented as Transformers, which transform one DataFrame into another, e.g., HashingTF. Some feature transformers are implemented as Estimators, because the transformation requires some aggregated information of the dataset, e.g., document frequencies in IDF. For those feature transformers, calling Estimator.fit is required to obtain the model first, e.g., IDFModel, in order to apply transformation. The transformation is usually done by appending new columns to the input DataFrame, so all input columns are carried over.

    We try to make each transformer minimal, so it becomes flexible to assemble feature transformation pipelines. Pipeline can be used to chain feature transformers, and VectorAssembler can be used to combine multiple feature transformations, for example:

    import org.apache.spark.ml.feature._
    import org.apache.spark.ml.Pipeline
    
    // a DataFrame with three columns: id (integer), text (string), and rating (double).
    val df = spark.createDataFrame(Seq(
      (0, "Hi I heard about Spark", 3.0),
      (1, "I wish Java could use case classes", 4.0),
      (2, "Logistic regression models are neat", 4.0)
    )).toDF("id", "text", "rating")
    
    // define feature transformers
    val tok = new RegexTokenizer()
      .setInputCol("text")
      .setOutputCol("words")
    val sw = new StopWordsRemover()
      .setInputCol("words")
      .setOutputCol("filtered_words")
    val tf = new HashingTF()
      .setInputCol("filtered_words")
      .setOutputCol("tf")
      .setNumFeatures(10000)
    val idf = new IDF()
      .setInputCol("tf")
      .setOutputCol("tf_idf")
    val assembler = new VectorAssembler()
      .setInputCols(Array("tf_idf", "rating"))
      .setOutputCol("features")
    
    // assemble and fit the feature transformation pipeline
    val pipeline = new Pipeline()
      .setStages(Array(tok, sw, tf, idf, assembler))
    val model = pipeline.fit(df)
    
    // save transformed features with raw data
    model.transform(df)
      .select("id", "text", "rating", "features")
      .write.format("parquet").save("/output/path")

    Some feature transformers implemented in MLlib are inspired by those implemented in scikit-learn. The major difference is that most scikit-learn feature transformers operate eagerly on the entire input dataset, while MLlib's feature transformers operate lazily on individual columns, which is more efficient and flexible to handle large and complex datasets.

    See also

    scikit-learn.preprocessing

  6. package fpm
  7. package image
  8. package linalg
  9. package param
  10. package recommendation
  11. package regression
  12. package source
  13. package stat
  14. package tree
  15. package tuning
  16. package util

Type Members

  1. abstract class Estimator[M <: Model[M]] extends PipelineStage

    Abstract class for estimators that fit models to data.

  2. case class FitEnd[M <: Model[M]]() extends MLEvent with Product with Serializable

    Event fired after Estimator.fit.

    Event fired after Estimator.fit.

    Annotations
    @Evolving()
  3. case class FitStart[M <: Model[M]]() extends MLEvent with Product with Serializable

    Event fired before Estimator.fit.

    Event fired before Estimator.fit.

    Annotations
    @Evolving()
  4. case class LoadInstanceEnd[T]() extends MLEvent with Product with Serializable

    Event fired after MLReader.load.

    Event fired after MLReader.load.

    Annotations
    @Evolving()
  5. case class LoadInstanceStart[T](path: String) extends MLEvent with Product with Serializable

    Event fired before MLReader.load.

    Event fired before MLReader.load.

    Annotations
    @Evolving()
  6. sealed trait MLEvent extends SparkListenerEvent

    Event emitted by ML operations.

    Event emitted by ML operations. Events are either fired before and/or after each operation (the event should document this).

    Annotations
    @Evolving()
    Note

    This is supported via Pipeline and PipelineModel.

  7. abstract class Model[M <: Model[M]] extends Transformer

    A fitted model, i.e., a Transformer produced by an Estimator.

    A fitted model, i.e., a Transformer produced by an Estimator.

    M

    model type

  8. class Pipeline extends Estimator[PipelineModel] with MLWritable

    A simple pipeline, which acts as an estimator.

    A simple pipeline, which acts as an estimator. A Pipeline consists of a sequence of stages, each of which is either an Estimator or a Transformer. When Pipeline.fit is called, the stages are executed in order. If a stage is an Estimator, its Estimator.fit method will be called on the input dataset to fit a model. Then the model, which is a transformer, will be used to transform the dataset as the input to the next stage. If a stage is a Transformer, its Transformer.transform method will be called to produce the dataset for the next stage. The fitted model from a Pipeline is a PipelineModel, which consists of fitted models and transformers, corresponding to the pipeline stages. If there are no stages, the pipeline acts as an identity transformer.

    Annotations
    @Since("1.2.0")
  9. class PipelineModel extends Model[PipelineModel] with MLWritable with Logging

    Represents a fitted pipeline.

    Represents a fitted pipeline.

    Annotations
    @Since("1.2.0")
  10. abstract class PipelineStage extends Params with Logging

    A stage in a pipeline, either an Estimator or a Transformer.

  11. abstract class PredictionModel[FeaturesType, M <: PredictionModel[FeaturesType, M]] extends Model[M] with PredictorParams

    Abstraction for a model for prediction tasks (regression and classification).

    Abstraction for a model for prediction tasks (regression and classification).

    FeaturesType

    Type of features. E.g., VectorUDT for vector features.

    M

    Specialization of PredictionModel. If you subclass this type, use this type parameter to specify the concrete type for the corresponding model.

  12. abstract class Predictor[FeaturesType, Learner <: Predictor[FeaturesType, Learner, M], M <: PredictionModel[FeaturesType, M]] extends Estimator[M] with PredictorParams

    Abstraction for prediction problems (regression and classification).

    Abstraction for prediction problems (regression and classification). It accepts all NumericType labels and will automatically cast it to DoubleType in fit(). If this predictor supports weights, it accepts all NumericType weights, which will be automatically casted to DoubleType in fit().

    FeaturesType

    Type of features. E.g., VectorUDT for vector features.

    Learner

    Specialization of this class. If you subclass this type, use this type parameter to specify the concrete type.

    M

    Specialization of PredictionModel. If you subclass this type, use this type parameter to specify the concrete type for the corresponding model.

  13. case class SaveInstanceEnd(path: String) extends MLEvent with Product with Serializable

    Event fired after MLWriter.save.

    Event fired after MLWriter.save.

    Annotations
    @Evolving()
  14. case class SaveInstanceStart(path: String) extends MLEvent with Product with Serializable

    Event fired before MLWriter.save.

    Event fired before MLWriter.save.

    Annotations
    @Evolving()
  15. case class TransformEnd() extends MLEvent with Product with Serializable

    Event fired after Transformer.transform.

    Event fired after Transformer.transform.

    Annotations
    @Evolving()
  16. case class TransformStart() extends MLEvent with Product with Serializable

    Event fired before Transformer.transform.

    Event fired before Transformer.transform.

    Annotations
    @Evolving()
  17. abstract class Transformer extends PipelineStage

    Abstract class for transformers that transform one dataset into another.

  18. abstract class UnaryTransformer[IN, OUT, T <: UnaryTransformer[IN, OUT, T]] extends Transformer with HasInputCol with HasOutputCol with Logging

    Abstract class for transformers that take one input column, apply transformation, and output the result as a new column.

Value Members

  1. object Pipeline extends MLReadable[Pipeline] with Serializable
    Annotations
    @Since("1.6.0")
  2. object PipelineModel extends MLReadable[PipelineModel] with Serializable
    Annotations
    @Since("1.6.0")
  3. object functions
    Annotations
    @Since("3.0.0")

Inherited from AnyRef

Inherited from Any

Members