> For the complete documentation index, see [llms.txt](https://doc.verteego.com/verteego-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.verteego.com/verteego-doc/pipelines/forecasting-pipelines/calculators/transformation/interval_index.md).

# interval\_index

## Usage

{% hint style="info" %}
Assign interval name for each intervals defined in config. \
Assign NaN when the value is not in any interval. \
Only work with integer for now.
{% endhint %}

This calculator can be used with the following method:

<mark style="color:red;">**`interval_index`**</mark>

Examples:

* Create size category based on the product dimension
* Create price category based on the product price

***

## Main Parameters

{% hint style="success" %}
**The bold options** represent the default values when the parameters are optional.
{% endhint %}

* *<mark style="color:blue;">input\_columns</mark>* \
  list of columns used as input of the calculators: The list of columns that will be used to fill the output column.
* *<mark style="color:blue;">output\_columns</mark>* \
  list of columns added by the calculators : Name of the filled column added to the dataset.
* *<mark style="color:blue;">global</mark>* *(true, **false)*** \
  Should this calculator be performed before data splitting during training for cross-validation
* *<mark style="color:blue;">steps</mark>* \[optionnal] *(**training, prediction**, postprocessing*)\
  List of steps in a pipeline where columns from this calculator are added to the data. Note that when the training option is listed, the calculator is actually added during preprocessing.
* *<mark style="color:blue;">store\_in\_model</mark>* \[optionnal] *(true, **false)*** \
  Please indicate whether the "calculated" columns by the calculator should be stored in the model or not to avoid recalculating them during prediction. This is only relevant if the calculated columns are added to both training and prediction. Without this parameter, the values will not be stored in the model. The following parameters only make sense if this parameter is set to *true*.
* *<mark style="color:blue;">stored\_columns</mark>* \[required if *<mark style="color:blue;">store\_in\_model</mark> is true*] \
  List indicating the columns to be stored among the *<mark style="color:blue;">output\_columns</mark>*.
* *<mark style="color:blue;">stored\_keys</mark>* \[required if *<mark style="color:blue;">store\_in\_model</mark> is true*] \
  List indicating the columns to use for identifying the correct values to join on the data for prediction among the stored values (logically, they are to be chosen from the *<mark style="color:blue;">input\_columns</mark>*).

***

## Specific Parameters

* *<mark style="color:blue;">value\_col</mark>* \
  The column used to identify interval.
* *<mark style="color:blue;">intervals</mark>* \
  Intervals, with their upper and lower bounds. Intervals are named in the resulting column using this parameter.

***

## Examples

1. Given a dataset with sales data with the price item information (`item_price` ), the user want classify the price into multiple category. The interval need to take into account all the different possibilities to avoid null value.

   ```yaml
   calculated_cols:
     intervals:
       method: interval_index
       input_columns:
       - item_price
       output_columns:
       - interval_column
       params:
         value_col: item_price
         intervals:
           cheap:
           - 0
           - 5
           medium:
           - 6
           - 50
         	upper:
         	- 50
         	- 200
         	expensive:
         	- 200
         	- 1000
   ```

   Input:

   | item\_price |
   | ----------- |
   | 1           |
   | 2           |
   | 7           |
   | 60          |
   | 600         |
   | 1200        |
   | 60.1        |
   | 1.2         |

   Output

   | item\_price | interval\_column |
   | ----------- | ---------------- |
   | 1           | cheap            |
   | 2           | cheap            |
   | 7           | medium           |
   | 60          | upper            |
   | 600         | expensive        |
   | 1200        |                  |
   | 60.1        |                  |
   | 1.2         |                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.verteego.com/verteego-doc/pipelines/forecasting-pipelines/calculators/transformation/interval_index.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
