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 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.

    Definition Classes
    ml
  • package classification
    Definition Classes
    ml
  • package clustering
    Definition Classes
    ml
  • package evaluation
    Definition Classes
    ml
  • 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.

    Definition Classes
    ml
    See also

    scikit-learn.preprocessing

  • package fpm
    Definition Classes
    ml
  • package image
    Definition Classes
    ml
  • package linalg
    Definition Classes
    ml
  • package param
    Definition Classes
    ml
  • package recommendation
    Definition Classes
    ml
  • package regression
    Definition Classes
    ml
  • AFTSurvivalRegression
  • AFTSurvivalRegressionModel
  • DecisionTreeRegressionModel
  • DecisionTreeRegressor
  • GBTRegressionModel
  • GBTRegressor
  • GeneralizedLinearRegression
  • GeneralizedLinearRegressionModel
  • GeneralizedLinearRegressionSummary
  • GeneralizedLinearRegressionTrainingSummary
  • IsotonicRegression
  • IsotonicRegressionModel
  • LinearRegression
  • LinearRegressionModel
  • LinearRegressionSummary
  • LinearRegressionTrainingSummary
  • RandomForestRegressionModel
  • RandomForestRegressor
  • RegressionModel
  • Regressor
  • package source
    Definition Classes
    ml
  • package stat
    Definition Classes
    ml
  • package tree
    Definition Classes
    ml
  • package tuning
    Definition Classes
    ml
  • package util
    Definition Classes
    ml
p

org.apache.spark.ml

regression

package regression

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class AFTSurvivalRegression extends Estimator[AFTSurvivalRegressionModel] with AFTSurvivalRegressionParams with DefaultParamsWritable with Logging

    Fit a parametric survival regression model named accelerated failure time (AFT) model (see Accelerated failure time model (Wikipedia)) based on the Weibull distribution of the survival time.

    Fit a parametric survival regression model named accelerated failure time (AFT) model (see Accelerated failure time model (Wikipedia)) based on the Weibull distribution of the survival time.

    Annotations
    @Since( "1.6.0" )
  2. class AFTSurvivalRegressionModel extends Model[AFTSurvivalRegressionModel] with AFTSurvivalRegressionParams with MLWritable

    Model produced by AFTSurvivalRegression.

    Model produced by AFTSurvivalRegression.

    Annotations
    @Since( "1.6.0" )
  3. class DecisionTreeRegressionModel extends PredictionModel[Vector, DecisionTreeRegressionModel] with DecisionTreeModel with DecisionTreeRegressorParams with MLWritable with Serializable

    Decision tree (Wikipedia) model for regression.

    Decision tree (Wikipedia) model for regression. It supports both continuous and categorical features.

    Annotations
    @Since( "1.4.0" )
  4. class DecisionTreeRegressor extends Predictor[Vector, DecisionTreeRegressor, DecisionTreeRegressionModel] with DecisionTreeRegressorParams with DefaultParamsWritable

    Decision tree learning algorithm for regression.

    Decision tree learning algorithm for regression. It supports both continuous and categorical features.

    Annotations
    @Since( "1.4.0" )
  5. class GBTRegressionModel extends PredictionModel[Vector, GBTRegressionModel] with GBTRegressorParams with TreeEnsembleModel[DecisionTreeRegressionModel] with MLWritable with Serializable

    Gradient-Boosted Trees (GBTs) model for regression.

    Gradient-Boosted Trees (GBTs) model for regression. It supports both continuous and categorical features.

    Annotations
    @Since( "1.4.0" )
  6. class GBTRegressor extends Predictor[Vector, GBTRegressor, GBTRegressionModel] with GBTRegressorParams with DefaultParamsWritable with Logging

    Gradient-Boosted Trees (GBTs) learning algorithm for regression.

    Gradient-Boosted Trees (GBTs) learning algorithm for regression. It supports both continuous and categorical features.

    The implementation is based upon: J.H. Friedman. "Stochastic Gradient Boosting." 1999.

    Notes on Gradient Boosting vs. TreeBoost:

    • This implementation is for Stochastic Gradient Boosting, not for TreeBoost.
    • Both algorithms learn tree ensembles by minimizing loss functions.
    • TreeBoost (Friedman, 1999) additionally modifies the outputs at tree leaf nodes based on the loss function, whereas the original gradient boosting method does not.
      • When the loss is SquaredError, these methods give the same result, but they could differ for other loss functions.
    • We expect to implement TreeBoost in the future: [https://issues.apache.org/jira/browse/SPARK-4240]
    Annotations
    @Since( "1.4.0" )
  7. class GeneralizedLinearRegression extends Regressor[Vector, GeneralizedLinearRegression, GeneralizedLinearRegressionModel] with GeneralizedLinearRegressionBase with DefaultParamsWritable with Logging

    Fit a Generalized Linear Model (see Generalized linear model (Wikipedia)) specified by giving a symbolic description of the linear predictor (link function) and a description of the error distribution (family).

    Fit a Generalized Linear Model (see Generalized linear model (Wikipedia)) specified by giving a symbolic description of the linear predictor (link function) and a description of the error distribution (family). It supports "gaussian", "binomial", "poisson", "gamma" and "tweedie" as family. Valid link functions for each family is listed below. The first link function of each family is the default one.

    • "gaussian" : "identity", "log", "inverse"
    • "binomial" : "logit", "probit", "cloglog"
    • "poisson" : "log", "identity", "sqrt"
    • "gamma" : "inverse", "identity", "log"
    • "tweedie" : power link function specified through "linkPower". The default link power in the tweedie family is 1 - variancePower.
    Annotations
    @Since( "2.0.0" )
  8. class GeneralizedLinearRegressionModel extends RegressionModel[Vector, GeneralizedLinearRegressionModel] with GeneralizedLinearRegressionBase with MLWritable with HasTrainingSummary[GeneralizedLinearRegressionTrainingSummary]

    Model produced by GeneralizedLinearRegression.

    Model produced by GeneralizedLinearRegression.

    Annotations
    @Since( "2.0.0" )
  9. class GeneralizedLinearRegressionSummary extends Serializable

    Summary of GeneralizedLinearRegression model and predictions.

    Summary of GeneralizedLinearRegression model and predictions.

    Annotations
    @Since( "2.0.0" )
  10. class GeneralizedLinearRegressionTrainingSummary extends GeneralizedLinearRegressionSummary with Serializable

    Summary of GeneralizedLinearRegression fitting and model.

    Summary of GeneralizedLinearRegression fitting and model.

    Annotations
    @Since( "2.0.0" )
  11. class IsotonicRegression extends Estimator[IsotonicRegressionModel] with IsotonicRegressionBase with DefaultParamsWritable

    Isotonic regression.

    Isotonic regression.

    Currently implemented using parallelized pool adjacent violators algorithm. Only univariate (single feature) algorithm supported.

    Uses org.apache.spark.mllib.regression.IsotonicRegression.

    Annotations
    @Since( "1.5.0" )
  12. class IsotonicRegressionModel extends Model[IsotonicRegressionModel] with IsotonicRegressionBase with MLWritable

    Model fitted by IsotonicRegression.

    Model fitted by IsotonicRegression. Predicts using a piecewise linear function.

    For detailed rules see org.apache.spark.mllib.regression.IsotonicRegressionModel.predict().

    Annotations
    @Since( "1.5.0" )
  13. class LinearRegression extends Regressor[Vector, LinearRegression, LinearRegressionModel] with LinearRegressionParams with DefaultParamsWritable with Logging

    Linear regression.

    Linear regression.

    The learning objective is to minimize the specified loss function, with regularization. This supports two kinds of loss:

    • squaredError (a.k.a squared loss)
    • huber (a hybrid of squared error for relatively small errors and absolute error for relatively large ones, and we estimate the scale parameter from training data)

    This supports multiple types of regularization:

    • none (a.k.a. ordinary least squares)
    • L2 (ridge regression)
    • L1 (Lasso)
    • L2 + L1 (elastic net)

    The squared error objective function is:

    $$ \begin{align} \min_{w}\frac{1}{2n}{\sum_{i=1}^n(X_{i}w - y_{i})^{2} + \lambda\left[\frac{1-\alpha}{2}{||w||_{2}}^{2} + \alpha{||w||_{1}}\right]} \end{align} $$

    The huber objective function is:

    $$ \begin{align} \min_{w, \sigma}\frac{1}{2n}{\sum_{i=1}^n\left(\sigma + H_m\left(\frac{X_{i}w - y_{i}}{\sigma}\right)\sigma\right) + \frac{1}{2}\lambda {||w||_2}^2} \end{align} $$

    where

    $$ \begin{align} H_m(z) = \begin{cases} z^2, & \text {if } |z| < \epsilon, \\ 2\epsilon|z| - \epsilon^2, & \text{otherwise} \end{cases} \end{align} $$

    Note: Fitting with huber loss only supports none and L2 regularization.

    Annotations
    @Since( "1.3.0" )
  14. class LinearRegressionModel extends RegressionModel[Vector, LinearRegressionModel] with LinearRegressionParams with GeneralMLWritable with HasTrainingSummary[LinearRegressionTrainingSummary]

    Model produced by LinearRegression.

    Model produced by LinearRegression.

    Annotations
    @Since( "1.3.0" )
  15. class LinearRegressionSummary extends Serializable

    Linear regression results evaluated on a dataset.

    Linear regression results evaluated on a dataset.

    Annotations
    @Since( "1.5.0" )
  16. class LinearRegressionTrainingSummary extends LinearRegressionSummary

    Linear regression training results.

    Linear regression training results. Currently, the training summary ignores the training weights except for the objective trace.

    Annotations
    @Since( "1.5.0" )
  17. class RandomForestRegressionModel extends PredictionModel[Vector, RandomForestRegressionModel] with RandomForestRegressorParams with TreeEnsembleModel[DecisionTreeRegressionModel] with MLWritable with Serializable

    Random Forest model for regression.

    Random Forest model for regression. It supports both continuous and categorical features.

    Annotations
    @Since( "1.4.0" )
  18. class RandomForestRegressor extends Predictor[Vector, RandomForestRegressor, RandomForestRegressionModel] with RandomForestRegressorParams with DefaultParamsWritable

    Random Forest learning algorithm for regression.

    Random Forest learning algorithm for regression. It supports both continuous and categorical features.

    Annotations
    @Since( "1.4.0" )
  19. abstract class RegressionModel[FeaturesType, M <: RegressionModel[FeaturesType, M]] extends PredictionModel[FeaturesType, M] with PredictorParams

    :: DeveloperApi ::

    :: DeveloperApi ::

    Model produced by a Regressor.

    FeaturesType

    Type of input features. E.g., org.apache.spark.mllib.linalg.Vector

    M

    Concrete Model type.

    Annotations
    @DeveloperApi()
  20. abstract class Regressor[FeaturesType, Learner <: Regressor[FeaturesType, Learner, M], M <: RegressionModel[FeaturesType, M]] extends Predictor[FeaturesType, Learner, M] with PredictorParams

    Single-label regression

    Single-label regression

    FeaturesType

    Type of input features. E.g., org.apache.spark.mllib.linalg.Vector

    Learner

    Concrete Estimator type

    M

    Concrete Model type

    Annotations
    @DeveloperApi()

Value Members

  1. object AFTSurvivalRegression extends DefaultParamsReadable[AFTSurvivalRegression] with Serializable
    Annotations
    @Since( "1.6.0" )
  2. object AFTSurvivalRegressionModel extends MLReadable[AFTSurvivalRegressionModel] with Serializable
    Annotations
    @Since( "1.6.0" )
  3. object DecisionTreeRegressionModel extends MLReadable[DecisionTreeRegressionModel] with Serializable
    Annotations
    @Since( "2.0.0" )
  4. object DecisionTreeRegressor extends DefaultParamsReadable[DecisionTreeRegressor] with Serializable
    Annotations
    @Since( "1.4.0" )
  5. object GBTRegressionModel extends MLReadable[GBTRegressionModel] with Serializable
    Annotations
    @Since( "2.0.0" )
  6. object GBTRegressor extends DefaultParamsReadable[GBTRegressor] with Serializable
    Annotations
    @Since( "1.4.0" )
  7. object GeneralizedLinearRegression extends DefaultParamsReadable[GeneralizedLinearRegression] with Serializable
    Annotations
    @Since( "2.0.0" )
  8. object GeneralizedLinearRegressionModel extends MLReadable[GeneralizedLinearRegressionModel] with Serializable
    Annotations
    @Since( "2.0.0" )
  9. object IsotonicRegression extends DefaultParamsReadable[IsotonicRegression] with Serializable
    Annotations
    @Since( "1.6.0" )
  10. object IsotonicRegressionModel extends MLReadable[IsotonicRegressionModel] with Serializable
    Annotations
    @Since( "1.6.0" )
  11. object LinearRegression extends DefaultParamsReadable[LinearRegression] with Serializable
    Annotations
    @Since( "1.6.0" )
  12. object LinearRegressionModel extends MLReadable[LinearRegressionModel] with Serializable
    Annotations
    @Since( "1.6.0" )
  13. object RandomForestRegressionModel extends MLReadable[RandomForestRegressionModel] with Serializable
    Annotations
    @Since( "2.0.0" )
  14. object RandomForestRegressor extends DefaultParamsReadable[RandomForestRegressor] with Serializable
    Annotations
    @Since( "1.4.0" )

Members