Packages

o

org.apache.spark.ml.stat

Summarizer

object Summarizer extends Logging

Tools for vectorized statistics on MLlib Vectors.

The methods in this package provide various statistics for Vectors contained inside DataFrames.

This class lets users pick the statistics they would like to extract for a given column. Here is an example in Scala:

import org.apache.spark.ml.linalg._
import org.apache.spark.sql.Row
val dataframe = ... // Some dataframe containing a feature column and a weight column
val multiStatsDF = dataframe.select(
    Summarizer.metrics("min", "max", "count").summary($"features", $"weight")
val Row(minVec, maxVec, count) = multiStatsDF.first()

If one wants to get a single metric, shortcuts are also available:

val meanDF = dataframe.select(Summarizer.mean($"features"))
val Row(meanVec) = meanDF.first()

Note: Currently, the performance of this interface is about 2x~3x slower than using the RDD interface.

Annotations
@Since( "2.3.0" )
Source
Summarizer.scala
Linear Supertypes
Logging, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Summarizer
  2. Logging
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def count(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  2. def count(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  3. def max(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  4. def max(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  5. def mean(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  6. def mean(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  7. def metrics(metrics: String*): SummaryBuilder

    Given a list of metrics, provides a builder that it turns computes metrics from a column.

    Given a list of metrics, provides a builder that it turns computes metrics from a column.

    See the documentation of Summarizer for an example.

    The following metrics are accepted (case sensitive):

    • mean: a vector that contains the coefficient-wise mean.
    • sum: a vector that contains the coefficient-wise sum.
    • variance: a vector that contains the coefficient-wise variance.
    • std: a vector that contains the coefficient-wise standard deviation.
    • count: the count of all vectors seen.
    • numNonzeros: a vector with the number of non-zeros for each coefficients
    • max: the maximum for each coefficient.
    • min: the minimum for each coefficient.
    • normL2: the Euclidean norm for each coefficient.
    • normL1: the L1 norm of each coefficient (sum of the absolute values).
    metrics

    metrics that can be provided.

    returns

    a builder.

    Annotations
    @Since( "2.3.0" ) @varargs()
    Exceptions thrown

    IllegalArgumentException if one of the metric names is not understood. Note: Currently, the performance of this interface is about 2x~3x slower than using the RDD interface.

  8. def min(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  9. def min(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  10. def normL1(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  11. def normL1(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  12. def normL2(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  13. def normL2(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  14. def numNonZeros(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  15. def numNonZeros(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )
  16. def std(col: Column): Column
    Annotations
    @Since( "3.0.0" )
  17. def std(col: Column, weightCol: Column): Column
    Annotations
    @Since( "3.0.0" )
  18. def sum(col: Column): Column
    Annotations
    @Since( "3.0.0" )
  19. def sum(col: Column, weightCol: Column): Column
    Annotations
    @Since( "3.0.0" )
  20. def variance(col: Column): Column
    Annotations
    @Since( "2.3.0" )
  21. def variance(col: Column, weightCol: Column): Column
    Annotations
    @Since( "2.3.0" )