2016-08-17 69 views
2

我有很多數據,我已經嘗試過基數分區[20k,200k +]。Spark :: KMeans調用兩次takeSample()?

我把它叫做這樣的:

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()一次。那麼爲什麼監視器顯示兩個takeSample() s每KMeans()

enter image description here

注:我執行更KMeans(),他們都援引2個takeSample() S,不管數據是.cache()「d與否。

此外,分區不影響數takeSample()叫的數量,這是不斷爲2

我使用星火1.6.2(我不能升級)和我的應用程序是在Python,如果那很重要!


我把這個給星火開發者的郵件列表,所以我更新:1日takeSample()

詳情:次takeSample()

enter image description here

詳情:

enter image description here

可以看到執行相同的代碼。

回答

1

如星火的郵件列表建議由Shivaram卡塔拉曼:

我覺得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()實際上只被調用過一次,但那只是熱空氣。