Skip to content

Commit

Permalink
some cleanups before sending to Xiangrui
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbradley committed May 11, 2015
1 parent 7431272 commit 66ce18c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
9 changes: 0 additions & 9 deletions python/pyspark/ml/param/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,3 @@ def _copyValues(self, to, extra={}):
if paramMap.has_key(p) and to.hasParam(p.name):
to._set((p.name, paramMap[p]))
return to

@staticmethod
def _copyParamMap(paramMap, to):
"""
Create a copy of the given ParamMap, but with parameter
:param paramMap:
:param to:
:return:
"""
17 changes: 12 additions & 5 deletions python/pyspark/ml/tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,21 @@ def fit(self, dataset, params={}):
def copy(self, extra={}):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This copies the underlying estimator, creates a deep copy of the embedded paramMap, and
copies the embedded and extra parameters over.
and some extra params. This copies the underlying estimator,
evaluator, and estimatorParamMap, creates a deep copy of the
embedded paramMap, and copies the embedded and extra parameters
over.
:param extra: Extra parameters to copy to the new instance
:return: Copy of this instance
"""
paramMap = self.extractParamMap(extra)
stages = map(lambda stage: stage.copy(extra), paramMap[self.stages])
return CrossValidator().setStages(stages)
newCV = Params.copy(self, extra)
if self.isSet(self.estimator):
newCV.setEstimator(self.getEstimator().copy(extra))
if self.isSet(self.estimatorParamMaps):
newCV.setEstimatorParamMaps(self.getEstimatorParamMaps().MAGIC_COPY_TO_BE_IMPLEMENTED(extra)) # TODO
if self.isSet(self.evaluator):
newCV.setEvaluator(self.getEvaluator().copy(extra))
return newCV


class CrossValidatorModel(Model):
Expand Down

0 comments on commit 66ce18c

Please sign in to comment.