Skip to content

Instantly share code, notes, and snippets.

@jaor
Last active December 20, 2018 04:57
Show Gist options
  • Save jaor/f6845ba6b4bf9fb5746ab9915df8c4f0 to your computer and use it in GitHub Desktop.
Save jaor/f6845ba6b4bf9fb5746ab9915df8c4f0 to your computer and use it in GitHub Desktop.
Create a model using only the most important features in another one
{
"name": "select-important",
"kind": "script",
"description": "Select the important features from an existig moddel to create a new one",
"source_code": "script.whizzml",
"imports":[
],
"inputs":[
{
"name": "model-id",
"type": "model-id",
"description": "Known model from which to infer important features"
},
{
"name": "feature-no",
"type": "number",
"description": "Number of important features to retain"
},
{
"name": "dataset-id",
"type": "dataset-id",
"description": "Dataset to model uisng the most important features"
}],
"outputs":[
{
"name": "model-id",
"type": "model-id",
"description": "The newly created model"
}]
}
(define (mark-fields ds-id prefix)
(let (fields (resource-fields ds-id)
ids (keys fields)
len (count prefix)
flags (for (f (values fields))
{"preferred" (not (= prefix (subs (f "name") 0 len)))}))
(update ds-id {"fields" (make-map ids flags)})))
(define result (mark-fields dataset-id prefix))
@jwveld
Copy link

jwveld commented Nov 24, 2018

The input should be any of the "models" and I see no difference between the input and output model. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment