Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

Summarizer#

classpyspark.ml.stat.Summarizer[source]#

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.

New in version 2.4.0.

Examples

>>>frompyspark.ml.statimportSummarizer>>>frompyspark.sqlimportRow>>>frompyspark.ml.linalgimportVectors>>>summarizer=Summarizer.metrics("mean","count")>>>df=sc.parallelize([Row(weight=1.0,features=Vectors.dense(1.0,1.0,1.0)),...Row(weight=0.0,features=Vectors.dense(1.0,2.0,3.0))]).toDF()>>>df.select(summarizer.summary(df.features,df.weight)).show(truncate=False)+-----------------------------------+|aggregate_metrics(features, weight)|+-----------------------------------+|{[1.0,1.0,1.0], 1}                 |+-----------------------------------+>>>df.select(summarizer.summary(df.features)).show(truncate=False)+--------------------------------+|aggregate_metrics(features, 1.0)|+--------------------------------+|{[1.0,1.5,2.0], 2}              |+--------------------------------+>>>df.select(Summarizer.mean(df.features,df.weight)).show(truncate=False)+--------------+|mean(features)|+--------------+|[1.0,1.0,1.0] |+--------------+>>>df.select(Summarizer.mean(df.features)).show(truncate=False)+--------------+|mean(features)|+--------------+|[1.0,1.5,2.0] |+--------------+

Methods

count(col[, weightCol])

return a column of count summary

max(col[, weightCol])

return a column of max summary

mean(col[, weightCol])

return a column of mean summary

metrics(*metrics)

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

min(col[, weightCol])

return a column of min summary

normL1(col[, weightCol])

return a column of normL1 summary

normL2(col[, weightCol])

return a column of normL2 summary

numNonZeros(col[, weightCol])

return a column of numNonZero summary

std(col[, weightCol])

return a column of std summary

sum(col[, weightCol])

return a column of sum summary

variance(col[, weightCol])

return a column of variance summary

Methods Documentation

staticcount(col,weightCol=None)[source]#

return a column of count summary

New in version 2.4.0.

staticmax(col,weightCol=None)[source]#

return a column of max summary

New in version 2.4.0.

staticmean(col,weightCol=None)[source]#

return a column of mean summary

New in version 2.4.0.

staticmetrics(*metrics)[source]#

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

See the documentation ofSummarizer 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).

New in version 2.4.0.

Returns
pyspark.ml.stat.SummaryBuilder

Notes

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

Examples

metricsstr

metrics that can be provided.

staticmin(col,weightCol=None)[source]#

return a column of min summary

New in version 2.4.0.

staticnormL1(col,weightCol=None)[source]#

return a column of normL1 summary

New in version 2.4.0.

staticnormL2(col,weightCol=None)[source]#

return a column of normL2 summary

New in version 2.4.0.

staticnumNonZeros(col,weightCol=None)[source]#

return a column of numNonZero summary

New in version 2.4.0.

staticstd(col,weightCol=None)[source]#

return a column of std summary

New in version 3.0.0.

staticsum(col,weightCol=None)[source]#

return a column of sum summary

New in version 3.0.0.

staticvariance(col,weightCol=None)[source]#

return a column of variance summary

New in version 2.4.0.


[8]ページ先頭

©2009-2025 Movatter.jp