如何对火花进行分位数离散化?
how to quantile-discretize on spark?
我想在没有 Spark.ML 的情况下将 RDD[Float] 分位数离散化为 10 个部分,所以我需要计算 10th-Percentile、20th-Percentile...80th-Percentile、90th-Percentile
数据集很大,无法收集到本地!
有什么有效的算法可以解决这个问题?
如果您使用的 Spark 版本 > 2.0,则已提供此功能。您必须将 RDD[Float] 转换为数据框。使用 DataFrameStatFunctions
中的 approxQuantile(String col, double[] probabilities, double relativeError)
。
从文档中说:
This method implements a variation of the Greenwald-Khanna algorithm
(with some speed optimizations). The algorithm was first present in
Space-efficient Online Computation of Quantile Summaries by Greenwald
and Khanna
我想在没有 Spark.ML 的情况下将 RDD[Float] 分位数离散化为 10 个部分,所以我需要计算 10th-Percentile、20th-Percentile...80th-Percentile、90th-Percentile
数据集很大,无法收集到本地!
有什么有效的算法可以解决这个问题?
如果您使用的 Spark 版本 > 2.0,则已提供此功能。您必须将 RDD[Float] 转换为数据框。使用 DataFrameStatFunctions
中的 approxQuantile(String col, double[] probabilities, double relativeError)
。
从文档中说:
This method implements a variation of the Greenwald-Khanna algorithm (with some speed optimizations). The algorithm was first present in Space-efficient Online Computation of Quantile Summaries by Greenwald and Khanna