×
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!
Evaluation of 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
Evaluation of category models
Details:
Created
Thu, 8 Oct 2026 15:00:00 +0000
Published
Thu, 8 Oct 2026 17:26:28 +0000
Description:
Perform an evaluation of per-category models
Tags:
BigMLer
BigMLer_ThuOct0826_165959
URL:
https://bigml.com/user/whizzml/gallery/script/6ac7aff0944055c6d74afbac
Script
FREE
Source code
;; Find field (define (find-field-id fields field) (or (and (contains? fields field) field) (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}})") name (str "Submodel for '" category "'")) (create-dataset dataset {"lisp_filter" fltr "name" name}))) ;; 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})))) ;; Compute average metric taking into account relative dataset ;; population (define (weighted-average total counts evaluations property) (let (xs (for (e evaluations) (e ["result" "model" property] 0))) (/ (iterate (v 0 c counts x xs) (+ v (* c x))) total))) ;; Delete resources ignoring errors (define (safe-delete id) (try (delete id) (catch e (log-info (str "Error deleting resource " id " ignored"))))) ;; Final workflow (define (evaluate 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")) evs (wait* (map (lambda (d m) (create-evaluation d m)) ds ms)) counts (for (d ds) ((fetch d) "rows" 0)) total (apply + counts) full-evs (map fetch evs) classification? (zero? ((head full-evs) "type")) metrics (if classification? ["accuracy" "average_f_measure" "average_precision" "average_recall"] ["mean_absolute_error" "mean_squared_error" "r_squared"]) av-metrics (for (m metrics) (weighted-average total counts full-evs m))) (when del? (map safe-delete ds)) (assoc (make-map metrics av-metrics) "evaluations" evs))) (define result (evaluate execution dataset clean-up?))
Description
Perform an evaluation of per-category models
Perform an evaluation of per-category models
Show more
Inputs
Outputs
License:
Creative Commons Zero V1.0
Script
FREE
Evaluation of category models | BigML.com
Sending Request...
Sending Request...