Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5926#discussion_r29731492
  
    --- Diff: python/pyspark/ml/tuning.py ---
    @@ -79,6 +85,173 @@ def build(self):
             return [dict(zip(keys, prod)) for prod in 
itertools.product(*grid_values)]
     
     
    +class CrossValidator(Estimator):
    +    """
    +    K-fold cross validation.
    +
    +    >>> from pyspark.ml.classification import LogisticRegression
    +    >>> from pyspark.ml.evaluation import BinaryClassificationEvaluator
    +    >>> from pyspark.mllib.linalg import Vectors
    +    >>> dataset = sqlContext.createDataFrame(
    +    ...     [(Vectors.dense([0.0, 1.0]), 0.0),
    +    ...      (Vectors.dense([1.0, 2.0]), 1.0),
    +    ...      (Vectors.dense([0.55, 3.0]), 0.0),
    +    ...      (Vectors.dense([0.45, 4.0]), 1.0),
    +    ...      (Vectors.dense([0.51, 5.0]), 1.0)] * 10,
    +    ...     ["features", "label"])
    +    >>> lr = LogisticRegression()
    +    >>> grid = ParamGridBuilder().addGrid(lr.maxIter, [0, 1, 5]).build()
    +    >>> evaluator = BinaryClassificationEvaluator()
    +    >>> cv = CrossValidator(estimator=lr, estimatorParamMaps=grid, 
evaluator=evaluator)
    +    >>> cvModel = cv.fit(dataset)
    +    >>> expected = lr.fit(dataset, {lr.maxIter: 5}).transform(dataset)
    +    >>> cvModel.transform(dataset).collect() == expected.collect()
    +    True
    +    """
    +
    +    # a placeholder to make it appear in the generated doc
    +    estimator = Param(Params._dummy(), "estimator", "estimator to be 
cross-validated")
    +
    +    # a placeholder to make it appear in the generated doc
    +    estimatorParamMaps = Param(Params._dummy(), "estimatorParamMaps", 
"estimator param maps")
    +
    +    # a placeholder to make it appear in the generated doc
    +    evaluator = Param(Params._dummy(), "evaluator", "evaluator for 
selection")
    --- End diff --
    
    Here and in Scala, we should say CrossValidator tries to maximize the 
evaluation metric.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to