# Categorizing Continuous Variables

**URL:** <https://discourse.datamethods.org/t/categorizing-continuous-variables/3402>\
**Category:** measurement\
**Tags:** categorization\
**Created:** [June 4, 2020, 11:24am UTC](https://discourse.datamethods.org/t/categorizing-continuous-variables/3402 "2020-06-04T11:24:58Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![R\_cubed](https://discourse.datamethods.org/user_avatar/discourse.datamethods.org/r_cubed/32/1518_2.png) [@R\_cubed](https://discourse.datamethods.org/u/R_cubed)\
**Post date:** [June 23, 2020, 2:37pm UTC](https://discourse.datamethods.org/t/categorizing-continuous-variables/3402/13 "2020-06-23T14:37:35Z")

</div>

I remembered this being discussed awhile back. Here is a link to the thread.

> [@Choosing a Classification probability threshold when using nested cross-validation](https://discourse.datamethods.org/t/choosing-a-classification-probability-threshold-when-using-nested-cross-validation/2802/9):
>
> Noted. But what to do if product requirements dictate sensitivity and specificity (a common scenario)? If you optimize something like Brier score or calibration instead, test may not meet the requirements even if it is theoretically optimal

I would also study the blog post Dr. Harrell mentioned in that thread. I post the link for your convenience.

> **[Classification vs. Prediction – Statistical Thinking](https://www.fharrell.com/post/classification/)**
>
> Classification involves a forced-choice premature decision, and is often misused in machine learning applications. Probability modeling involves the quantification of tendencies and usually addresses the real project goals.

I guess the key point is: in order to maximize the use of the information available, all inputs are kept in a continuous form until the actual time a decision needs to be made.

When you think about it as an engineer, physicist, or numerical analyst might, this makes sense in terms of the procedure maintaining numerical stability.

Every approximation of a continuous quantity introduces error. When more error is introduced during the modelling process (ie. in the terms of a regression model), the more difficult it is to place reliable bounds upon the output of the model. A small change in inputs could lead to a very large change in outputs.

> **[Discretization error](https://en.wikipedia.org/wiki/Discretization_error)**
>
> In numerical analysis, computational physics, and simulation, discretization error is the error resulting from the fact that a function of a continuous variable is represented in the computer by a finite number of evaluations, for example, on a lattice. Discretization error can usually be reduced by using a more finely spaced lattice, with an increased computational cost.
> Discretization error is the principal source of error in methods of finite differences and the pseudo-spectral method of co...

If you think about this in a regression context, the least amount of error is introduced if we dichotomize at the point in time when an item needs to be classified (when element x is inserted into set categories Y\_1,... Y\_N).

So the simple answer is: “Don’t dichotomize until the end of the modelling process.”

A more complicated answer is: “Any approximation introduced in the modelling process must be examined for the error it introduces.” There are other theorems that can guide the modeller on when an approximation can be inserted for a continuous quantity.

Addendum: I think this link is a more general discussion of the issue of mapping a continuous function (outputs of some model) to a discrete one (ie. choice/decison function).

> **[Quantization (signal processing)](https://en.wikipedia.org/wiki/Quantization_(signal_processing))**
>
> Quantization, in mathematics and digital signal processing, is the process of mapping input values from a large set (often a continuous set) to output values in a (countable) smaller set, often with a finite number of elements. Rounding and truncation are typical examples of quantization processes. Quantization is involved to some degree in nearly all digital signal processing, as the process of representing a signal in digital form ordinarily involves rounding. Quantization also forms the c...

> **[Discretization](https://en.wikipedia.org/wiki/Discretization)**
>
> In applied mathematics, discretization is the process of transferring continuous functions, models, variables, and equations into discrete counterparts. This process is usually carried out as a first step toward making them suitable for numerical evaluation and implementation on digital computers. Dichotomization is the special case of discretization in which the number of discrete classes is 2, which can approximate a continuous variable as a binary variable (creating a dichotomy for modeling p...

---

_[View the full topic](https://discourse.datamethods.org/t/categorizing-continuous-variables/3402)._
