×
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!
Stratified split | 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
Stratified Split
Details:
Created
Thu, 8 Oct 2026 15:04:43 +0000
Published
Thu, 8 Oct 2026 17:25:28 +0000
Description:
An implementation of stratified split
Tags:
BigMLer
BigMLer_ThuOct0826_170443
URL:
https://bigml.com/user/whizzml/gallery/script/6ac7b10b6a59afed275e4836
Script
FREE
Source code
;; Transposes the matrix: [[a b] [c d]] to [[a c] [b d]] (define (_transpose m) (apply map list m)) ;; Deletes resources ignoring errors (define (safe-delete id) (try (delete id) (catch e (log-info (str "Error deleting resource " id " ignored:" e)) false))) ;; Check that the objective field exists and is a categorical field (define (check-cat fields objective-field) (let (field (find-field fields objective-field)) (when (not (find-field fields objective-field)) (raise {"message" (str "The objective field " objective-field " cannot be found in this dataset") "code" 100})) (when (not (categorical-field? field)) (raise {"message" (str "The objective field " objective-field " is not a categorical field." " Only categorical fields can be used.") "code" 101})))) ;; Function to apply stratified split with a given training-rate to the ;; objective field (define (stratified-split-fn ds-id training-rate objective-field) (let (dataset (fetch ds-id) ds-name (dataset "name") fields (resource-fields dataset) _ (check-cat fields objective-field) objective-id ((find-field fields objective-field) "id") summary (dataset ["fields" objective-id "summary" "categories"] [[]]) cat-names (map head summary) cat-ds-ids (for (cat cat-names) (create-dataset-split (create-dataset {"origin_dataset" ds-id "lisp_filter" (flatline "(= " "(f {{objective-id}})" " {{cat}})") "name" (str (dataset "name") " - " cat)}) training-rate "bigml")) inner-ds (created-resources) ds-ids (map (lambda (ids name) (merge-datasets ids {"name" name})) (_transpose cat-ds-ids) [(str ds-name " - train (" (* training-rate 100) "%)") (str ds-name " - test (" (round (* 100 (- 1 training-rate))) "%)")])) (wait* ds-ids) (map safe-delete inner-ds) ds-ids)) (define stratified-split (stratified-split-fn ds-id training-rate objective-field)) ;; Separate Output Datasets (define training-ds (head stratified-split)) (define test-ds (stratified-split 1))
Description
An implementation of stratified split
An implementation of stratified split
Show more
Inputs
Outputs
License:
Creative Commons Zero V1.0
Script
FREE
Stratified split | BigML.com
Sending Request...
Sending Request...