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
  • BinaryClassificationEvaluator
  • ClusteringEvaluator
  • ClusteringMetrics
  • Evaluator
  • MulticlassClassificationEvaluator
  • MultilabelClassificationEvaluator
  • RankingEvaluator
  • RegressionEvaluator
  • 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
  • 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

evaluation

package evaluation

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class BinaryClassificationEvaluator extends Evaluator with HasRawPredictionCol with HasLabelCol with HasWeightCol with DefaultParamsWritable

    Evaluator for binary classification, which expects input columns rawPrediction, label and an optional weight column.

    Evaluator for binary classification, which expects input columns rawPrediction, label and an optional weight column. The rawPrediction column can be of type double (binary 0/1 prediction, or probability of label 1) or of type vector (length-2 vector of raw predictions, scores, or label probabilities).

    Annotations
    @Since( "1.2.0" )
  2. class ClusteringEvaluator extends Evaluator with HasPredictionCol with HasFeaturesCol with HasWeightCol with DefaultParamsWritable

    Evaluator for clustering results.

    Evaluator for clustering results. The metric computes the Silhouette measure using the specified distance measure.

    The Silhouette is a measure for the validation of the consistency within clusters. It ranges between 1 and -1, where a value close to 1 means that the points in a cluster are close to the other points in the same cluster and far from the points of the other clusters.

    Annotations
    @Since( "2.3.0" )
  3. class ClusteringMetrics extends AnyRef

    Metrics for clustering, which expects two input columns: prediction and label.

    Metrics for clustering, which expects two input columns: prediction and label.

    Annotations
    @Since( "3.1.0" )
  4. abstract class Evaluator extends Params

    Abstract class for evaluators that compute metrics from predictions.

    Abstract class for evaluators that compute metrics from predictions.

    Annotations
    @Since( "1.5.0" )
  5. class MulticlassClassificationEvaluator extends Evaluator with HasPredictionCol with HasLabelCol with HasWeightCol with HasProbabilityCol with DefaultParamsWritable

    Evaluator for multiclass classification, which expects input columns: prediction, label, weight (optional) and probability (only for logLoss).

    Evaluator for multiclass classification, which expects input columns: prediction, label, weight (optional) and probability (only for logLoss).

    Annotations
    @Since( "1.5.0" )
  6. class MultilabelClassificationEvaluator extends Evaluator with HasPredictionCol with HasLabelCol with DefaultParamsWritable

    :: Experimental :: Evaluator for multi-label classification, which expects two input columns: prediction and label.

    :: Experimental :: Evaluator for multi-label classification, which expects two input columns: prediction and label.

    Annotations
    @Since( "3.0.0" ) @Experimental()
  7. class RankingEvaluator extends Evaluator with HasPredictionCol with HasLabelCol with DefaultParamsWritable

    :: Experimental :: Evaluator for ranking, which expects two input columns: prediction and label.

    :: Experimental :: Evaluator for ranking, which expects two input columns: prediction and label.

    Annotations
    @Experimental() @Since( "3.0.0" )
  8. final class RegressionEvaluator extends Evaluator with HasPredictionCol with HasLabelCol with HasWeightCol with DefaultParamsWritable

    Evaluator for regression, which expects input columns prediction, label and an optional weight column.

    Evaluator for regression, which expects input columns prediction, label and an optional weight column.

    Annotations
    @Since( "1.4.0" )

Value Members

  1. object BinaryClassificationEvaluator extends DefaultParamsReadable[BinaryClassificationEvaluator] with Serializable
    Annotations
    @Since( "1.6.0" )
  2. object ClusteringEvaluator extends DefaultParamsReadable[ClusteringEvaluator] with Serializable
    Annotations
    @Since( "2.3.0" )
  3. object MulticlassClassificationEvaluator extends DefaultParamsReadable[MulticlassClassificationEvaluator] with Serializable
    Annotations
    @Since( "1.6.0" )
  4. object MultilabelClassificationEvaluator extends DefaultParamsReadable[MultilabelClassificationEvaluator] with Serializable
    Annotations
    @Since( "3.0.0" )
  5. object RankingEvaluator extends DefaultParamsReadable[RankingEvaluator] with Serializable
    Annotations
    @Since( "3.0.0" )
  6. object RegressionEvaluator extends DefaultParamsReadable[RegressionEvaluator] with Serializable
    Annotations
    @Since( "1.6.0" )

Members