Skip to content

Commit 1fab73f

Browse files
author
Louis Pouillot
committed
add pred type and wait for guess params in method analysis.create_prediction_mltask
1 parent d695351 commit 1fab73f

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

dataikuapi/dss/analysis.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,24 @@ def set_definition(self, definition):
152152
# ML
153153
########################################################
154154

155-
def create_prediction_ml_task(self, target_variable,
156-
ml_backend_type = "PY_MEMORY",
157-
guess_policy = "DEFAULT"):
158-
159-
155+
def create_prediction_ml_task(self,
156+
target_variable,
157+
ml_backend_type="PY_MEMORY",
158+
guess_policy="DEFAULT",
159+
prediction_type=None,
160+
wait_guess_complete=True):
160161
"""Creates a new prediction task in this visual analysis lab
161162
for a dataset.
162163
163-
164-
The returned ML task will be in 'guessing' state, i.e. analyzing
165-
the input dataset to determine feature handling and algorithms.
166-
167-
You should wait for the guessing to be completed by calling
168-
``wait_guess_complete`` on the returned object before doing anything
169-
else (in particular calling ``train`` or ``get_settings``)
170-
164+
:param string target_variable: Variable to predict
171165
:param string ml_backend_type: ML backend to use, one of PY_MEMORY, MLLIB or H2O
172166
:param string guess_policy: Policy to use for setting the default parameters. Valid values are: DEFAULT, SIMPLE_FORMULA, DECISION_TREE, EXPLANATORY and PERFORMANCE
167+
:param string prediction_type: The type of prediction problem this is. If not provided the prediction type will be guessed. Valid values are: BINARY_CLASSIFICATION, REGRESSION, MULTICLASS
168+
:param boolean wait_guess_complete: if False, the returned ML task will be in 'guessing' state, i.e. analyzing the input dataset to determine feature handling and algorithms.
169+
You should wait for the guessing to be completed by calling
170+
``wait_guess_complete`` on the returned object before doing anything
171+
else (in particular calling ``train`` or ``get_settings``)
172+
:return :class dataiku.dss.ml.DSSMLTask
173173
"""
174174

175175
obj = {
@@ -178,9 +178,14 @@ def create_prediction_ml_task(self, target_variable,
178178
"backendType": ml_backend_type,
179179
"guessPolicy": guess_policy
180180
}
181-
181+
if prediction_type is not None:
182+
obj["predictionType"] = prediction_type
182183
ref = self.client._perform_json("POST", "/projects/%s/lab/%s/models/" % (self.project_key, self.analysis_id), body=obj)
183-
return DSSMLTask(self.client, self.project_key, self.analysis_id, ref["mlTaskId"])
184+
mltask = DSSMLTask(self.client, self.project_key, self.analysis_id, ref["mlTaskId"])
185+
186+
if wait_guess_complete:
187+
mltask.wait_guess_complete()
188+
return mltask
184189

185190
def create_clustering_ml_task(self,
186191
ml_backend_type = "PY_MEMORY",

dataikuapi/dss/ml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ def redeploy_to_flow(self, model_id, recipe_name=None, saved_model_id=None, acti
923923

924924
def start_guess(self,
925925
prediction_type=None,
926-
wait_guess_complete=True):
926+
wait_guess_complete=False):
927927
"""
928928
Guess the feature handling and the algorithms.
929929
:param string prediction_type: In case of a prediction problem the prediction type can be specify. Valid values are BINARY_CLASSIFICATION, REGRESSION, MULTICLASS.

0 commit comments

Comments
 (0)