本文整理匯總了Python中pyspark.ml.tuning.CrossValidator.setParallelism方法的典型用法代碼示例。如果您正苦於以下問題:Python CrossValidator.setParallelism方法的具體用法?Python CrossValidator.setParallelism怎麽用?Python CrossValidator.setParallelism使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyspark.ml.tuning.CrossValidator
的用法示例。
在下文中一共展示了CrossValidator.setParallelism方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_parallel_evaluation
# 需要導入模塊: from pyspark.ml.tuning import CrossValidator [as 別名]
# 或者: from pyspark.ml.tuning.CrossValidator import setParallelism [as 別名]
def test_parallel_evaluation(self):
dataset = self.spark.createDataFrame(
[(Vectors.dense([0.0]), 0.0),
(Vectors.dense([0.4]), 1.0),
(Vectors.dense([0.5]), 0.0),
(Vectors.dense([0.6]), 1.0),
(Vectors.dense([1.0]), 1.0)] * 10,
["features", "label"])
lr = LogisticRegression()
grid = ParamGridBuilder().addGrid(lr.maxIter, [5, 6]).build()
evaluator = BinaryClassificationEvaluator()
# test save/load of CrossValidator
cv = CrossValidator(estimator=lr, estimatorParamMaps=grid, evaluator=evaluator)
cv.setParallelism(1)
cvSerialModel = cv.fit(dataset)
cv.setParallelism(2)
cvParallelModel = cv.fit(dataset)
self.assertEqual(cvSerialModel.avgMetrics, cvParallelModel.avgMetrics)