Last active
July 11, 2018 16:54
-
-
Save jaor/76c1eb276efcc9d06c67bbd6b84d59c7 to your computer and use it in GitHub Desktop.
Filtered timeseries
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": "Filtered timeseries", | |
"kind": "script", | |
"description": "Takes a filter field and an objective field and creates a timeseries for each category in the filter field, collecting all resulting forecasts in a new dataset", | |
"source_code": "script.whizzml", | |
"inputs":[ | |
{ | |
"name": "dataset", | |
"type": "dataset-id", | |
"description": "Input dataset" | |
}, | |
{ | |
"name": "filtered-field", | |
"type": "string", | |
"description": "Field to be used for filtering rows" | |
}, | |
{ | |
"name": "objective-field", | |
"type": "string", | |
"description": "Timeseries objective field" | |
}], | |
"outputs":[ | |
{ | |
"name": "forecasts-dataset", | |
"type": "dataset-id", | |
"description": "Dataset with all resulting forecasts and their bounds" | |
}] | |
} | |
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 number-of-terms-in-topic-name 2) | |
(define (topic-name topic) | |
(let (terms (take number-of-terms-in-topic-name (topic "top_terms"))) | |
(join "_" (map head terms)))) | |
(define (rename-topics tm-id) | |
(let (tm (fetch tm-id) | |
topics (reduce (lambda (ns topic) | |
(assoc ns (topic "id") {"name" (topic-name topic)})) | |
{} | |
(tm ["topic_model" "topics"]))) | |
(update tm-id {"topics" topics}) | |
(count topics))) | |
(define result (rename-topics topic-model)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment