> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# discretize_on_values

> Discretize column by binning its values using explicitly specified cuts points. 

Each bin can optionally be assigned a label.

## Usage

The following example shows how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      The following parameters will discretize a column with values in the range \[0, 1], producing a new categorical column with bins (0, 0.33], (0.33, 0.66], (0.66, 1] (i.e. right-inclusive). The bins will be labelled "low", "medium", and "high" respectively.

      ```stan theme={null}
      discretize_on_values(ds.price, {"cuts": [0.33, 0.66], "add_extremes": true, "labels": ["low", "medium", "high"]}) -> (ds.price_category)
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      discretize_on_values(input: number, {
          "param": value,
          ...
      }) -> (output: category)
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="input" type="column[number]" required>
    A quantitative column to discretize.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="output" type="column[category]" required>
    A new categorical column with categories corresponding to discretized bins.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="cuts" type="array[number]" default="[0.33, 0.66]">
    Points/values used to cut the quantitative column into bins.

    <Accordion title="Array items">
      <ParamField path="Item" type="number">
        Each item in array.
      </ParamField>
    </Accordion>
  </ParamField>

  <ParamField path="labels" type="array[string]" default="['low', 'medium', 'high']">
    Names for the resulting bins.
    *Important: Note that cutting a series of values in 3 places creates 4 bins.*.

    <Accordion title="Array items">
      <ParamField path="Item" type="string">
        Each item in array.
      </ParamField>
    </Accordion>
  </ParamField>

  <ParamField path="add_extremes" type="boolean" default="true">
    Whether to automatically include the minimum and maximum values of the column as cut points.
  </ParamField>

  <ParamField path="include_right" type="boolean" default="true">
    Whether the intervals are right-inclusive, i.e. of the form `(x1, x2]`, or left-inclusive `[x1, x2)`.
  </ParamField>
</Accordion>
