Fork me on GitHub

bucket

Puts numbers into custom-sized buckets. Useful for histograms.

The bucket transform allows you to put numbers into buckets of custom size.

For example, given this data:

2,16,84,-5,1

We can choose buckets of size 10 (starting from 0 by default)

bucket(10)

to get:

"[0,10)", "[10,20)", "[80,90)","[-10,0)","[0,10)"

The bucket transform uses interval notation. To process the range in code, you can manually change the last character from ) to ], and parse the result as a json array.

Histograms

Using the bucket transform in conjunction with the map transform, it is easy to generate histograms:

map(bucket(10),count)

Running this transform on the above data will give:

[{
  "[-10,0)": 1,
  "[0,10)": 2,
  "[10,20)": 1,
  "[80,90)": 1
}]

Transform Details

One-To-OneStatelessPeekInput SchemaOutput Schema
TrueTrueFalse{"type": "string"}

Arguments

#DescriptionOptionalConstantHijackedDefault
1The size of each bucket (float)TrueTrueFalse10
2Start location for bucketingTrueTrueFalse0

This Site

Contribute

ConnectorDB is a very new open-source project. If you are a designer/developer or ML enthusiast, head on over to the connectordb github, where you can choose which part of ConnectorDB you want to contribute towards! Pull requests or bug reports are welcome!