×
BigML is working hard to support a wide range of browsers. Your experience will be better with:
English
Sign up / in
Sign up
Sign in
or Sign in with...
Amazon
Github
GitLab
Google
Toggle navigation
PRODUCT
Features
Releases
What's New
GETTING STARTED
PRICING
Subscriptions
Private Deployments
Training
Certifications
BigML for Education
SUPPORT
Toggle navigation
PRODUCT
Features
Releases
What's New
GETTING STARTED
PRICING
Subscriptions
Private Deployments
Training
Certifications
BigML for Education
SUPPORT
License
Oops!
We could not process your request!
Batch predictions with category models | BigML.com
×
Embed this Script in your web site
Copy & Paste this code into your HTML code:
whizzml
Public
whizzml's
Scripts
77
Models
0
Datasets
0
0
FREE
BUY
Batch predictions with category models
Details:
Created
Thu, 8 Oct 2026 15:00:04 +0000
Published
Thu, 8 Oct 2026 17:26:28 +0000
Description:
Perform a batch prediction using per-category models
Tags:
BigMLer
BigMLer_ThuOct0826_170003
URL:
https://bigml.com/user/whizzml/gallery/script/6ac7aff412163ebf324fb4df
Script
FREE
Source code
;; Find field (define (find-field-id fields field) (or (fields field false) (loop (ids (keys fields)) (cond (empty? ids) false (= field (fields [(head ids) "name"] "")) (head ids) (recur (tail ids)))))) ;; Extracts the result of the given execution, signaling an ;; error if it's not of the expected kind. (define (exec-result eid) (let (res ((fetch eid) ["execution" "result"] {}) ks (if (res "binary" false) ["category"] ["categories" "missings-model"])) (for (k (concat ["models" "field-id" "field-name" "kind"] ks)) (when (not (contains? res k)) (raise (str "Invalid execution: Missing field " k " in result")))) res)) ;; Given a parent dataset, a field and one of its categories, ;; create a new dataset containing only the instances of the parent ;; that have the given given category. (define (category-dataset dataset field category) (let (fltr (flatline "(= (f {{field}}) {{category}})")) (create-dataset dataset {"lisp_filter" fltr}))) ;; Create a dataset for missing values of field (define (missings-dataset dataset field) (let (missings ((fetch dataset) ["fields" field "summary" "missing_count"] 0)) (when (positive? missings) (create-dataset dataset {"lisp_filter" (flatline "(missing? {{field}})")})))) ;; Split a dataset extracting a given category (define (split-on-category dataset id cat) (let (fl (flatline "(= (f {{id}}) {{cat}})") nfl (flatline "(!= (f {{id}}) {{cat}})")) (for (f [fl nfl]) (create-dataset dataset {"lisp_filter" f})))) ;; Delete resources ignoring errors (define (safe-delete id) (try (delete id) (catch e (log-info (str "Error deleting resource " id " ignored"))))) ;; Final workflow (define (predict-by-category eid dataset del?) (let (res (exec-result eid) fds ((fetch dataset) "fields") fid (or (find-field-id fds (res "field-name")) (find-field-id fds (res "field-id")) (raise (str "The input dataset does not contain " (res "field-name")))) ds (if (res "binary") (split-on-category dataset fid (res "category")) (for (c (res "categories")) (category-dataset dataset fid c))) mm (res "missings-model" false) md (when mm (missings-dataset dataset fid)) ds (if (and mm md) (cons md ds) ds) ms (if (and mm md) (cons mm (res "models")) (res "models")) bps (map (lambda (d m) (create-batchprediction d m {"output_dataset" true "all_fields" true "confidence" true})) ds ms) bds (map (lambda (bp) ((fetch (wait bp)) "output_dataset_resource")) bps) pds (create-and-wait-dataset {"origin_datasets" (wait* bds)})) (when del? (map safe-delete (concat bps bds ds))) pds)) (define result (predict-by-category execution dataset clean-up?))
Description
Perform a batch prediction using per-category models
Perform a batch prediction using per-category models
Show more
Inputs
Outputs
License:
Creative Commons Zero V1.0
Script
FREE
Batch predictions with category models | BigML.com
Sending Request...
Sending Request...