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
  • BisectingKMeans
  • BisectingKMeansModel
  • BisectingKMeansSummary
  • ClusteringSummary
  • DistributedLDAModel
  • GaussianMixture
  • GaussianMixtureModel
  • GaussianMixtureSummary
  • KMeans
  • KMeansModel
  • KMeansSummary
  • LDA
  • LDAModel
  • LocalLDAModel
  • PowerIterationClustering
  • 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
  • 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

clustering

package clustering

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class BisectingKMeans extends Estimator[BisectingKMeansModel] with BisectingKMeansParams with DefaultParamsWritable

    A bisecting k-means algorithm based on the paper "A comparison of document clustering techniques" by Steinbach, Karypis, and Kumar, with modification to fit Spark.

    A bisecting k-means algorithm based on the paper "A comparison of document clustering techniques" by Steinbach, Karypis, and Kumar, with modification to fit Spark. The algorithm starts from a single cluster that contains all points. Iteratively it finds divisible clusters on the bottom level and bisects each of them using k-means, until there are k leaf clusters in total or no leaf clusters are divisible. The bisecting steps of clusters on the same level are grouped together to increase parallelism. If bisecting all divisible clusters on the bottom level would result more than k leaf clusters, larger clusters get higher priority.

    Annotations
    @Since( "2.0.0" )
    See also

    Steinbach, Karypis, and Kumar, A comparison of document clustering techniques, KDD Workshop on Text Mining, 2000.

  2. class BisectingKMeansModel extends Model[BisectingKMeansModel] with BisectingKMeansParams with MLWritable with HasTrainingSummary[BisectingKMeansSummary]

    Model fitted by BisectingKMeans.

    Model fitted by BisectingKMeans.

    Annotations
    @Since( "2.0.0" )
  3. class BisectingKMeansSummary extends ClusteringSummary

    Summary of BisectingKMeans.

    Summary of BisectingKMeans.

    Annotations
    @Since( "2.1.0" )
  4. class ClusteringSummary extends Serializable

    Summary of clustering algorithms.

  5. class DistributedLDAModel extends LDAModel

    Distributed model fitted by LDA.

    Distributed model fitted by LDA. This type of model is currently only produced by Expectation-Maximization (EM).

    This model stores the inferred topics, the full training dataset, and the topic distribution for each training document.

    Annotations
    @Since( "1.6.0" )
  6. class GaussianMixture extends Estimator[GaussianMixtureModel] with GaussianMixtureParams with DefaultParamsWritable

    Gaussian Mixture clustering.

    Gaussian Mixture clustering.

    This class performs expectation maximization for multivariate Gaussian Mixture Models (GMMs). A GMM represents a composite distribution of independent Gaussian distributions with associated "mixing" weights specifying each's contribution to the composite.

    Given a set of sample points, this class will maximize the log-likelihood for a mixture of k Gaussians, iterating until the log-likelihood changes by less than convergenceTol, or until it has reached the max number of iterations. While this process is generally guaranteed to converge, it is not guaranteed to find a global optimum.

    Annotations
    @Since( "2.0.0" )
    Note

    This algorithm is limited in its number of features since it requires storing a covariance matrix which has size quadratic in the number of features. Even when the number of features does not exceed this limit, this algorithm may perform poorly on high-dimensional data. This is due to high-dimensional data (a) making it difficult to cluster at all (based on statistical/theoretical arguments) and (b) numerical issues with Gaussian distributions.

  7. class GaussianMixtureModel extends Model[GaussianMixtureModel] with GaussianMixtureParams with MLWritable with HasTrainingSummary[GaussianMixtureSummary]

    Multivariate Gaussian Mixture Model (GMM) consisting of k Gaussians, where points are drawn from each Gaussian i with probability weights(i).

    Multivariate Gaussian Mixture Model (GMM) consisting of k Gaussians, where points are drawn from each Gaussian i with probability weights(i).

    Annotations
    @Since( "2.0.0" )
  8. class GaussianMixtureSummary extends ClusteringSummary

    Summary of GaussianMixture.

    Summary of GaussianMixture.

    Annotations
    @Since( "2.0.0" )
  9. class KMeans extends Estimator[KMeansModel] with KMeansParams with DefaultParamsWritable

    K-means clustering with support for k-means|| initialization proposed by Bahmani et al.

    K-means clustering with support for k-means|| initialization proposed by Bahmani et al.

    Annotations
    @Since( "1.5.0" )
    See also

    Bahmani et al., Scalable k-means++.

  10. class KMeansModel extends Model[KMeansModel] with KMeansParams with GeneralMLWritable with HasTrainingSummary[KMeansSummary]

    Model fitted by KMeans.

    Model fitted by KMeans.

    Annotations
    @Since( "1.5.0" )
  11. class KMeansSummary extends ClusteringSummary

    Summary of KMeans.

    Summary of KMeans.

    Annotations
    @Since( "2.0.0" )
  12. class LDA extends Estimator[LDAModel] with LDAParams with DefaultParamsWritable

    Latent Dirichlet Allocation (LDA), a topic model designed for text documents.

    Latent Dirichlet Allocation (LDA), a topic model designed for text documents.

    Terminology:

    • "term" = "word": an element of the vocabulary
    • "token": instance of a term appearing in a document
    • "topic": multinomial distribution over terms representing some concept
    • "document": one piece of text, corresponding to one row in the input data

    Original LDA paper (journal version): Blei, Ng, and Jordan. "Latent Dirichlet Allocation." JMLR, 2003.

    Input data (featuresCol): LDA is given a collection of documents as input data, via the featuresCol parameter. Each document is specified as a Vector of length vocabSize, where each entry is the count for the corresponding term (word) in the document. Feature transformers such as org.apache.spark.ml.feature.Tokenizer and org.apache.spark.ml.feature.CountVectorizer can be useful for converting text to word count vectors.

    Annotations
    @Since( "1.6.0" )
    See also

    Latent Dirichlet allocation (Wikipedia)

  13. abstract class LDAModel extends Model[LDAModel] with LDAParams with Logging with MLWritable

    Model fitted by LDA.

    Model fitted by LDA.

    Annotations
    @Since( "1.6.0" )
  14. class LocalLDAModel extends LDAModel

    Local (non-distributed) model fitted by LDA.

    Local (non-distributed) model fitted by LDA.

    This model stores the inferred topics only; it does not store info about the training dataset.

    Annotations
    @Since( "1.6.0" )
  15. class PowerIterationClustering extends PowerIterationClusteringParams with DefaultParamsWritable

    Power Iteration Clustering (PIC), a scalable graph clustering algorithm developed by Lin and Cohen.

    Power Iteration Clustering (PIC), a scalable graph clustering algorithm developed by Lin and Cohen. From the abstract: PIC finds a very low-dimensional embedding of a dataset using truncated power iteration on a normalized pair-wise similarity matrix of the data.

    This class is not yet an Estimator/Transformer, use assignClusters method to run the PowerIterationClustering algorithm.

    Annotations
    @Since( "2.4.0" )
    See also

    Spectral clustering (Wikipedia)

Value Members

  1. object BisectingKMeans extends DefaultParamsReadable[BisectingKMeans] with Serializable
    Annotations
    @Since( "2.0.0" )
  2. object BisectingKMeansModel extends MLReadable[BisectingKMeansModel] with Serializable
  3. object DistributedLDAModel extends MLReadable[DistributedLDAModel] with Serializable
    Annotations
    @Since( "1.6.0" )
  4. object GaussianMixture extends DefaultParamsReadable[GaussianMixture] with Serializable
    Annotations
    @Since( "2.0.0" )
  5. object GaussianMixtureModel extends MLReadable[GaussianMixtureModel] with Serializable
    Annotations
    @Since( "2.0.0" )
  6. object KMeans extends DefaultParamsReadable[KMeans] with Serializable
    Annotations
    @Since( "1.6.0" )
  7. object KMeansModel extends MLReadable[KMeansModel] with Serializable
    Annotations
    @Since( "1.6.0" )
  8. object LDA extends MLReadable[LDA] with Serializable
    Annotations
    @Since( "2.0.0" )
  9. object LocalLDAModel extends MLReadable[LocalLDAModel] with Serializable
    Annotations
    @Since( "1.6.0" )
  10. object PowerIterationClustering extends DefaultParamsReadable[PowerIterationClustering] with Serializable
    Annotations
    @Since( "2.4.0" )

Members