Skip to content

Instantly share code, notes, and snippets.

@jaor
Last active November 9, 2017 04:31
Show Gist options
  • Save jaor/1327c4f5f0de38e531f2cb0c96f4376a to your computer and use it in GitHub Desktop.
Save jaor/1327c4f5f0de38e531f2cb0c96f4376a to your computer and use it in GitHub Desktop.
Create batch prediction dataset with predictions from multiple models
{
"name": "Muti-model predictions",
"kind": "script",
"description": "Generate predictions for a fixed number of models",
"source_code": "multibatch.whizzml",
"inputs":[
{
"name": "model1",
"type": "model-id",
"description": "first model"
},
{
"name": "model2",
"type": "model-id",
"description": "second model"
},
{
"name": "model3",
"type": "model-id",
"description": "third model"
},
{
"name": "model4",
"type": "model-id",
"description": "fourth model"
},
{
"name": "model5",
"type": "model-id",
"description": "fith model"
},
{
"name": "input-dataset",
"type": "dataset-id",
"description": "inputs used to create predictions"
}],
"outputs":[
{
"name": "result",
"type": "dataset-id",
"description": "output dataset with all predictions"
}]
}
(define (batch-dataset id)
((fetch (wait id)) "output_dataset_resource"))
(define (make-batch ds-id mod-id)
(let (mod (fetch mod-id)
name (str "prediction from " (mod "name")))
(create-batchprediction ds-id mod-id {"all_fields" true
"output_dataset" true
"prediction_name" name})))
(define (create-predictions models ds-id)
(reduce (lambda (did mid) (batch-dataset (make-batch did mid))) ds-id models))
(define result (create-predictions [model1 model2 model3 model4 model5] input-dataset))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment