-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding getBestModel and getBestModelInfo to TuneHyperparameters and f…
…ixed autogenerated code for model name (#355)
- Loading branch information
1 parent
0351dfe
commit d287118
Showing
6 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/tune-hyperparameters/src/main/python/TuneHyperparameters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (C) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE in project root for information. | ||
|
||
import sys | ||
from pyspark import SQLContext | ||
from pyspark import SparkContext | ||
|
||
if sys.version >= '3': | ||
basestring = str | ||
|
||
from mmlspark._TuneHyperparameters import _TuneHyperparameters | ||
from mmlspark._TuneHyperparameters import _TuneHyperparametersModel | ||
from pyspark.ml.wrapper import JavaParams | ||
from pyspark.ml.common import inherit_doc | ||
|
||
@inherit_doc | ||
class TuneHyperparameters(_TuneHyperparameters): | ||
def _create_model(self, java_model): | ||
model = TuneHyperparametersModel() | ||
model._java_obj = java_model | ||
model._transfer_params_from_java() | ||
return model | ||
|
||
@inherit_doc | ||
class TuneHyperparametersModel(_TuneHyperparametersModel): | ||
def getBestModel(self): | ||
""" | ||
Returns the best model. | ||
""" | ||
return JavaParams._from_java(self._java_obj.getBestModel()) | ||
|
||
def getBestModelInfo(self): | ||
""" | ||
Returns the best model parameter info. | ||
""" | ||
return self._java_obj.getBestModelInfo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters