spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JeremyNixon <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12877] [ML] Add train-validation-split ...
Date Fri, 26 Feb 2016 22:13:05 GMT
Github user JeremyNixon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11335#discussion_r54309484
  
    --- Diff: python/pyspark/ml/tuning.py ---
    @@ -288,6 +289,195 @@ def copy(self, extra=None):
             return CrossValidatorModel(self.bestModel.copy(extra))
     
     
    +class TrainValidationSplit(Estimator, HasSeed):
    +    """
    +    Train-Validation-Split.
    +    >>> 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]), 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, [0, 1]).build()
    +    >>> evaluator = BinaryClassificationEvaluator()
    +    >>> tvs = TrainValidationSplit(estimator=lr, estimatorParamMaps=grid, evaluator=evaluator)
    +    >>> tvsModel = tvs.fit(dataset)
    +    >>> evaluator.evaluate(tvsModel.transform(dataset))
    +    0.8333...
    +
    +    .. versionadded:: 2.0.0
    +    """
    +
    +    estimator = Param(Params._dummy(), "estimator", "estimator to be tested")
    +    estimatorParamMaps = Param(Params._dummy(), "estimatorParamMaps", "estimator param
maps")
    +    evaluator = Param(
    +        Params._dummy(), "evaluator",
    +        "evaluator used to select hyper-parameters that maximize the validated metric")
    +    trainRatio = Param(Params._dummy(), "trainRatio", "Param for ratio between train
and\
    +     validation data. Must be between 0 and 1.")
    +
    +    @keyword_only
    +    def __init__(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,
    +                 seed=None):
    +        """
    +        __init__(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,\
    +                 seed=None)
    +        """
    +        super(TrainValidationSplit, self).__init__()
    +        self._setDefault(trainRatio=0.75)
    +        kwargs = self.__init__._input_kwargs
    +        self._set(**kwargs)
    +
    +    @since("2.0.0")
    +    @keyword_only
    +    def setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=0.75,
    +                  seed=None):
    +        """
    +        setParams(self, estimator=None, estimatorParamMaps=None, evaluator=None, trainRatio=
0.75,\
    --- End diff --
    
    Updated.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message