Github user WeichenXu123 commented on a diff in the pull request:
https://github.com/apache/spark/pull/19122#discussion_r136933807
--- Diff: python/pyspark/ml/tuning.py ---
@@ -255,18 +257,23 @@ def _fit(self, dataset):
randCol = self.uid + "_rand"
df = dataset.select("*", rand(seed).alias(randCol))
metrics = [0.0] * numModels
+
+ pool = ThreadPool(processes=min(self.getParallelism(), numModels))
+
for i in range(nFolds):
validateLB = i * h
validateUB = (i + 1) * h
condition = (df[randCol] >= validateLB) & (df[randCol] <
validateUB)
- validation = df.filter(condition)
+ validation = df.filter(condition).cache()
--- End diff --
Suppose we have already cached input dataset, then generate "training
dataset" only need a "map" operation on cached df with filtering out only
`1/numFolds`. So I think the cost won't be too much more compared with caching
"training dataset".
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]