Skip to content

Commit cc11956

Browse files
Valentin Thoreyinstanceofme
andauthored
Feature/dss10 api evaluate recipe creation (#162)
* Add egg-info to gitignore * Add EvaluationRecipeCreator * Fix typos and pep8 * Improve documentation of EvaluationRecipeCreator * Fix documentation typo. * Pep8 and removed redefinition of unused class * Correct typo * Revert "Pep8 and removed redefinition of unused class" This reverts commit ee76fc3. * Update naming Co-authored-by: Adrien Lavoillotte <adrien.lavoillotte@dataiku.com> Co-authored-by: Adrien Lavoillotte <adrien.lavoillotte@dataiku.com>
1 parent 93e6c87 commit cc11956

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.pyc
22
.idea
33
*.iml
4+
egg-info

dataikuapi/dss/project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,8 @@ def new_recipe(self, type, name=None):
13331333
return recipe.PrepareRecipeCreator(name, self)
13341334
elif type == "prediction_scoring":
13351335
return recipe.PredictionScoringRecipeCreator(name, self)
1336+
elif type == "evaluation":
1337+
return recipe.EvaluationRecipeCreator(name, self)
13361338
elif type == "clustering_scoring":
13371339
return recipe.ClusteringScoringRecipeCreator(name, self)
13381340
elif type == "download":

dataikuapi/dss/recipe.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def run(self, job_type="NON_RECURSIVE_FORCED_BUILD", partitions=None, wait=True,
8989
"COMPUTABLE_FOLDER": "MANAGED_FOLDER",
9090
"COMPUTABLE_SAVED_MODEL": "SAVED_MODEL",
9191
"COMPUTABLE_STREAMING_ENDPOINT": "STREAMING_ENDPOINT",
92+
"COMPUTABLE_MODEL_EVALUATION_STORE": "MODEL_EVALUATION_STORE"
9293
}
9394
if first_output["type"] in object_type_map:
9495
jd = project.new_job(job_type)
@@ -1320,6 +1321,61 @@ def with_input_model(self, model_id):
13201321
return self._with_input(model_id, self.project.project_key, "model")
13211322

13221323

1324+
class EvaluationRecipeCreator(DSSRecipeCreator):
1325+
"""
1326+
Builder for the creation of a new "Evaluate" recipe, from an
1327+
input dataset, with an input saved model identifier
1328+
1329+
.. code-block:: python
1330+
1331+
# Create a new prediction scoring recipe outputing to a new dataset
1332+
1333+
project = client.get_project("MYPROJECT")
1334+
builder = EvaluationRecipeCreator("my_scoring_recipe", project)
1335+
builder.with_input_model(saved_model_id)
1336+
builder.with_input("dataset_to_evaluate")
1337+
1338+
builder.with_output("output_scored")
1339+
builder.with_output_metrics("output_metrics")
1340+
builder.with_output_evaluation_store(evaluation_store_id)
1341+
1342+
new_recipe = builder.build()
1343+
1344+
Outputs must exist. They can be created using the following:
1345+
1346+
.. code-block:: python
1347+
1348+
builder = project.new_managed_dataset("output_scored")
1349+
builder.with_store_into(connection)
1350+
dataset = builder.create()
1351+
1352+
builder = project.new_managed_dataset("output_scored")
1353+
builder.with_store_into(connection)
1354+
dataset = builder.create()
1355+
1356+
evaluation_store_id = project.create_model_evaluation_store("output_model_evaluation").id
1357+
"""
1358+
1359+
def __init__(self, name, project):
1360+
DSSRecipeCreator.__init__(self, 'evaluation', name, project)
1361+
1362+
def with_input_model(self, model_id):
1363+
"""Sets the input model"""
1364+
return self._with_input(model_id, self.project.project_key, "model")
1365+
1366+
def with_output(self, name):
1367+
"""Sets the ouput dataset containing the scored input"""
1368+
return self._with_output(name, role="main")
1369+
1370+
def with_output_metrics(self, name):
1371+
"""Sets the output dataset containing the metrics"""
1372+
return self._with_output(name, role="metrics")
1373+
1374+
def with_output_evaluation_store(self, name):
1375+
"""Sets the output model evaluation store"""
1376+
return self._with_output(name, role="evaluationStore")
1377+
1378+
13231379
class ClusteringScoringRecipeCreator(SingleOutputRecipeCreator):
13241380
"""
13251381
Builder for the creation of a new "Clustering scoring" recipe, from an

0 commit comments

Comments
 (0)