Spark::KMeans 调用 takeSample() 两次?
Spark::KMeans calls takeSample() twice?
我有很多数据,我已经尝试过基数 [20k, 200k+] 的分区。
我是这样称呼它的:
from pyspark.mllib.clustering import KMeans, KMeansModel
C0 = KMeans.train(first, 8192, initializationMode='random', maxIterations=10, seed=None)
C0 = KMeans.train(second, 8192, initializationMode='random', maxIterations=10, seed=None)
我看到 initRandom() 调用了 takeSample()
一次。
然后 takeSample() 实现似乎没有调用自身或类似的东西,所以我希望 KMeans()
调用 takeSample()
一次。那么为什么显示器每 KMeans()
显示两个 takeSample()
?
注意:我执行了更多KMeans()
,它们都调用了两个takeSample()
,不管数据是否.cache()
。
此外,分区的数量不影响takeSample()
被调用的次数,它是常数2。
我正在使用 Spark 1.6.2(我无法升级)并且我的应用程序在 Python,如果这很重要的话!
我把它带到了 Spark 开发人员的邮件列表中,所以我正在更新:
第一个 takeSample()
的详细信息:
第二个 takeSample()
的详细信息:
在哪里可以看到执行了相同的代码。
正如 Shivaram Venkataraman 在 Spark 的邮件列表中所建议的:
我认为 takeSample 本身会运行多个作业,如果样本数量
第一关收集的是不够的。注释和代码路径
在 GitHub
应该解释何时发生这种情况。您也可以通过以下方式确认
检查 logWarning 是否出现在您的日志中。
// If the first sample didn't turn out large enough, keep trying to take samples;
// this shouldn't happen often because we use a big multiplier for the initial size
var numIters = 0
while (samples.length < num) {
logWarning(s"Needed to re-sample due to insufficient sample size. Repeat #$numIters")
samples = this.sample(withReplacement, fraction, rand.nextInt()).collect()
numIters += 1
}
然而,正如大家所见,第二条评论说它不应该经常发生,而且它确实发生在我身上,所以如果有人有其他想法,请告诉我。
也有人认为这是 UI 的问题,takeSample()
实际上只调用了一次,但那只是空谈。
我有很多数据,我已经尝试过基数 [20k, 200k+] 的分区。
我是这样称呼它的:
from pyspark.mllib.clustering import KMeans, KMeansModel
C0 = KMeans.train(first, 8192, initializationMode='random', maxIterations=10, seed=None)
C0 = KMeans.train(second, 8192, initializationMode='random', maxIterations=10, seed=None)
我看到 initRandom() 调用了 takeSample()
一次。
然后 takeSample() 实现似乎没有调用自身或类似的东西,所以我希望 KMeans()
调用 takeSample()
一次。那么为什么显示器每 KMeans()
显示两个 takeSample()
?
注意:我执行了更多KMeans()
,它们都调用了两个takeSample()
,不管数据是否.cache()
。
此外,分区的数量不影响takeSample()
被调用的次数,它是常数2。
我正在使用 Spark 1.6.2(我无法升级)并且我的应用程序在 Python,如果这很重要的话!
我把它带到了 Spark 开发人员的邮件列表中,所以我正在更新:
第一个 takeSample()
的详细信息:
第二个 takeSample()
的详细信息:
在哪里可以看到执行了相同的代码。
正如 Shivaram Venkataraman 在 Spark 的邮件列表中所建议的:
我认为 takeSample 本身会运行多个作业,如果样本数量 第一关收集的是不够的。注释和代码路径 在 GitHub 应该解释何时发生这种情况。您也可以通过以下方式确认 检查 logWarning 是否出现在您的日志中。
// If the first sample didn't turn out large enough, keep trying to take samples;
// this shouldn't happen often because we use a big multiplier for the initial size
var numIters = 0
while (samples.length < num) {
logWarning(s"Needed to re-sample due to insufficient sample size. Repeat #$numIters")
samples = this.sample(withReplacement, fraction, rand.nextInt()).collect()
numIters += 1
}
然而,正如大家所见,第二条评论说它不应该经常发生,而且它确实发生在我身上,所以如果有人有其他想法,请告诉我。
也有人认为这是 UI 的问题,takeSample()
实际上只调用了一次,但那只是空谈。