Return-Path: X-Original-To: apmail-spark-reviews-archive@minotaur.apache.org Delivered-To: apmail-spark-reviews-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B4190181C5 for ; Fri, 26 Feb 2016 22:13:06 +0000 (UTC) Received: (qmail 81196 invoked by uid 500); 26 Feb 2016 22:13:06 -0000 Delivered-To: apmail-spark-reviews-archive@spark.apache.org Received: (qmail 81173 invoked by uid 500); 26 Feb 2016 22:13:06 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 81162 invoked by uid 99); 26 Feb 2016 22:13:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Feb 2016 22:13:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E29E1E0211; Fri, 26 Feb 2016 22:13:05 +0000 (UTC) From: JeremyNixon To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request: [SPARK-12877] [ML] Add train-validation-split ... Content-Type: text/plain Message-Id: <20160226221305.E29E1E0211@git1-us-west.apache.org> Date: Fri, 26 Feb 2016 22:13:05 +0000 (UTC) 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