Last active
June 24, 2019 22:07
-
-
Save jaor/d99ab863ef36e90465140f50940318f6 to your computer and use it in GitHub Desktop.
Anomalies above threshold
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
{ | |
"name": "Anomalies above threshold", | |
"kind": "script", | |
"description": "Creates a dataset with all the anomalies above a given threshold", | |
"source_code": "script.whizzml", | |
"imports":[ | |
], | |
"inputs":[ | |
{ | |
"name": "anomaly", | |
"type": "anomaly-id", | |
"description": "Anomaly to use" | |
}, | |
{ | |
"name": "threshold", | |
"type": "number", | |
"description": "Anomaly score threshold (0-100)" | |
}], | |
"outputs":[ | |
{ | |
"name": "dataset", | |
"type": "dataset-id", | |
"description": "Dataset with instances with a score equal or above `threshold`" | |
}] | |
} |
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
(define (batch-threshold anomaly threshold) | |
(when (not (<= 0 threshold 100)) | |
(raise "Threshold must be in the range [0, 100]")) | |
(let (dataset (resource-property anomaly "dataset") | |
ba (create-batchanomalyscore anomaly dataset {"output_dataset" true | |
"all_fields" true}) | |
ds (resource-property (wait ba) "output_dataset_resource") | |
th (/ threshold 100) | |
fltr (flatline "(>= (f \"score\") {th})") | |
fds (wait (create-dataset ds {"lisp_filter" fltr}))) | |
(delete* [ba ds]) | |
fds)) | |
(define dataset (batch-threshold anomaly threshold)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment