# 分类变量

分类变量是一种变量，其取值来自一个有限、通常固定的类别集合，用以描述观测对象的某种特征，如血型、诊断或客户满意度水平，而不是用数字表示的可测量数量。<sup>[1](https://pandas.pydata.org/docs/user_guide/categorical.html)</sup><sup> • </sup><sup>[2](https://tuos-bio-data-skills.github.io/intro-stats-book/data-variables.html)</sup> 由于取值是标签而非数量，变量类型会影响统计方法的选择，并且应在研究设计时仔细考虑。<sup>[3](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)</sup>

| 关键事实 | 详情 |
|---|---|
| 类型 | 名义（无排序，如发色）、有序（有排序但非数值，如满意度水平），二分类作为名义的特例<sup>[4](https://stats.oarc.ucla.edu/other/mult-pkg/whatstat/what-is-the-difference-between-categorical-ordinal-and-interval-variables/)</sup><sup> • </sup><sup>[3](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)</sup> |
| 回归编码 | 对具有 c 个类别的变量，在含截距模型中常用的一种满秩参考编码使用 c−1 个指示变量；将全部 c 个指示变量与截距一起使用会使设计矩阵秩亏（虚拟变量陷阱）<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup> |
| 自由度 | 一个 K 类别预测变量消耗 K−1 个自由度，而不是单个连续系数的 1 个自由度<sup>[6](https://support.sas.com/resources/papers/proceedings09/248-2009.pdf)</sup> |
| 树分裂 | 一个 k 类别特征有 2^(k−1) − 1 种可能的二分区，但高效回归树算法可在约 O(k log k) 时间内找到最优分区<sup>[7](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup> |
| 高基数编码 | 在一项跨五种算法的大型基准测试中，采用 5 折交叉验证的 GLMM 编码除 SVM 外对所有算法均排名第一<sup>[8](https://link.springer.com/article/10.1007/s00180-022-01207-6)</sup> |
| 软件存储 | R 因子存储整数编码加一个字符型 levels 属性；pandas 分类数据存储一个 categories 数组加一个整数 codes 数组<sup>[9](https://search.r-project.org/R/refmans/base/html/factor.html)</sup><sup> • </sup><sup>[1](https://pandas.pydata.org/docs/user_guide/categorical.html)</sup> |
| 近期工具 | scikit-learn 的 HistGradientBoosting 估计器支持原生分类特征和 TargetEncoder，XGBoost 3.1 增加了对新的 dataframe 输入的自动重新编码<sup>[10](https://scikit-learn.org/1.8/auto_examples/ensemble/plot_gradient_boosting_categorical.html)</sup><sup> • </sup><sup>[11](https://xgboost.readthedocs.io/en/stable/tutorials/categorical.html)</sup> |

## 定义与类型

一种常见分类法将变量分为名义或分类（二分类或二分变量作为特例）、有序和数值。<sup>[3](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)</sup> 名义变量基于每个类别内的计数描述分组，没有定量关系，也不能排序；发色有金发、棕发、深棕发和红发等类别，从高到低没有公认排序。<sup>[12](https://www.ncbi.nlm.nih.gov/books/NBK557882/)</sup><sup> • </sup><sup>[4](https://stats.oarc.ucla.edu/other/mult-pkg/whatstat/what-is-the-difference-between-categorical-ordinal-and-interval-variables/)</sup> 有序变量有顺序但没有关联数值，如从“非常不满意”向上的客户满意度水平。<sup>[13](https://link.springer.com/article/10.1186/s40537-020-00305-w)</sup>

有序数据与等距数据之间的形式边界可以用有效比较来表述：如果一个变量两个数据点的唯一有效数学比较是相等以及一个是否大于另一个，则该变量为有序；如果数据点之间的差值提供有效比较，则为等距。<sup>[14](https://stats.libretexts.org/Courses/Northern_Illinois_University/Data_and_the_Modern_World/05%3A_The_Nature_of_Data/5.03%3A_The_Structure_of_Data)</sup> 在史蒂文斯（Stevens）的框架中，四种尺度类型由它们所允许的变换来定义：名义尺度允许任何一一变换，有序尺度允许任何单调变换，等距尺度允许线性变换，比率尺度只允许具有有意义零点的乘法变换。<sup>[15](https://www.mdpi.com/2624-8611/5/2/18)</sup>

术语因作者而异：有些用“分类”同时包括名义变量和有序变量，有些只用于名义变量，而“分类”是比“名义”更常见的名称。<sup>[16](http://biostathandbook.com/variabletypes.html)</sup>

## 表示与编码

**为什么原始编码会误导。** 数值数组既有顺序又有大小，但分类变量即使是有序的也没有大小；使用数值数组意味着类别之间存在一个已知的“距离”，而这种距离并不存在。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup> 等到回归进入矩阵计算时，等距预测变量和分类预测变量之间已不作区分，因为“矩阵代数程序对不同类型数字一无所知；它们都只是数字”，所以原始数值编码可能悄悄产生误导性结果。<sup>[17](https://public.dhe.ibm.com/software/analytics/spss/support/Stats/Docs/Statistics/Articles/catreg1.htm)</sup> 数值编码是任意的：说 2[“男”] 是 1[“女”] 的两倍大小毫无意义。<sup>[2](https://tuos-bio-data-skills.github.io/intro-stats-book/data-variables.html)</sup> 将任意整数编码分配给无序类别，例如合同 = 1.0 和团体 = 2.0，是错误的，因为这意味着一种尺度。<sup>[18](https://aml4td.org/chapters/categorical-predictors.html)</sup>

**虚拟编码与独热编码。** 解决办法是把类别编码为取 0 和 1 的指示变量。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup> 在虚拟编码中，每个非参考类别创建一个 0/1 指示变量；当所有虚拟变量都等于零时，观测属于参考类别，系数相对于该参考水平解释。<sup>[19](https://stats.oarc.ucla.edu/spss/faq/coding-systems-for-categorical-variables-in-regression-analysis/)</sup><sup> • </sup><sup>[20](https://cscu.cornell.edu/wp-content/uploads/catvars.pdf)</sup> 一个有 c 个类别的变量在含截距模型中必须只用 c−1 个指示变量表示，因为完整集合线性相关，设计矩阵不满秩且不可逆，即虚拟变量陷阱。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup> 独热编码，也称单元均值编码，则为所有水平创建指示变量而不含截距列，因此线性回归估计值是每个水平的平均响应；独热编码常用于非线性模型，尤其是神经网络和基于树的模型，不过后者通常并不需要指示变量。<sup>[18](https://aml4td.org/chapters/categorical-predictors.html)</sup> 效应编码使用 1、0 和 −1，用 −1 表示最后一个类别，而不是用全零表示参考组。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup>

**软件存储。** R 的 factor 函数将向量编码为因子（也使用“类别”和“枚举类型”这些术语）；如果参数 ordered 为 TRUE，则假定水平有序，有序因子的类为 c("ordered", "factor")。<sup>[9](https://search.r-project.org/R/refmans/base/html/factor.html)</sup> 因子存储一组整数编码，并带有一个模式为 character 的“levels”属性，其中包含唯一条目。<sup>[9](https://search.r-project.org/R/refmans/base/html/factor.html)</sup> R 文档警告说，对因子应用 as.numeric 毫无意义，且可能通过隐式强制转换发生。<sup>[9](https://search.r-project.org/R/refmans/base/html/factor.html)</sup> pandas 的 Categorical 数据类型对应统计学上的分类变量，取有限、通常固定数量的可能值（类别；在 R 中称为水平）；内部由一个类别数组和一个指向它的整数编码数组组成，与统计学分类变量不同，它可以有顺序，但不能进行加法和除法等数值运算。<sup>[1](https://pandas.pydata.org/docs/user_guide/categorical.html)</sup> 在 SPSS 中，若干过程（T-TEST、ONEWAY、ANOVA、MANOVA、LOGISTIC REGRESSION、COX REGRESSION）会自动将分类预测变量转换为等距表示，但用户仍需理解该表示才能正确解释结果。<sup>[17](https://public.dhe.ibm.com/software/analytics/spss/support/Stats/Docs/Statistics/Articles/catreg1.htm)</sup> MATLAB 的 fitlm、fitglm 和 fitcox 使用参考组虚拟编码，而 fitlme 和 fitglme 允许用户通过 'DummyVarCoding' 参数选择 'full'、'reference' 或 'effects' 编码。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup>

## 分类数据分析

卡方检验通过考察变量各类别的频数和比例来确定分类变量之间的关系；根据变量情况，费希尔精确检验和麦克尼马尔检验等变体和扩展可能适用。<sup>[12](https://www.ncbi.nlm.nih.gov/books/NBK557882/)</sup> 对于分类结局的回归，名义和有序因变量需要超出标准二分类逻辑回归的自身建模方法。<sup>[21](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurit%C3%A0_Kr%C3%A0lovstv%C3%AC/18%3A_Nominal_and_Ordinal_Dependent_Variables)</sup> 具有多个有序类别的有序结局可以用多项逻辑回归或有序回归分析；在一个具体演算示例中，将每个严重程度与症状轻微的患者比较，类别大小从 140 到 2645 不等。<sup>[3](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)</sup> 阿格雷斯蒂（Agresti）的分类数据分析教材规定了有序变量应如何与名义变量区别对待，以及离散数据的泊松和负二项回归。<sup>[22](https://onlinelibrary.wiley.com/doi/book/10.1002/0471249688)</sup>

## 按数字看

将一个 K 类别变量作为分类变量处理会消耗 K−1 个自由度，而不是单个连续系数的 1 个自由度，这是因为分类的冗余性。<sup>[6](https://support.sas.com/resources/papers/proceedings09/248-2009.pdf)</sup> 这一成本随水平数增加而增加：一个 c 水平因子在截距模型中需要 c−1 个指示变量。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup> 对于树模型，一个 k 类别特征有 2^(k−1) − 1 种可能的二分区，但高效算法可在约 O(k log k) 时间内找到最优分区。<sup>[7](https://lightgbm.readthedocs.io/en/latest/Features.html)</sup> 在编码基准测试中，采用 5 折交叉验证的 glmm 编码除 SVM 外对所有机器学习算法均排名第一，而 10 折交叉验证没有提高性能，表明 5 折可作为实用的正则化默认值。<sup>[8](https://link.springer.com/article/10.1007/s00180-022-01207-6)</sup>

## 与二分类、计数和连续变量的比较

数值变量用数字描述可测量数量，而分类变量描述观测对象的特征；数值变量分为等距和比率尺度，分类变量分为名义和有序。<sup>[2](https://tuos-bio-data-skills.github.io/intro-stats-book/data-variables.html)</sup> 没有总体上“最好”的变量类型；研究设计时应谨慎选择类型。<sup>[3](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)</sup> 权衡是双向的：如果一个预测变量与结局恰好呈线性关系，将其离散化会损失信息，但分类处理可以捕捉复杂得多的非线性关系。<sup>[6](https://support.sas.com/resources/papers/proceedings09/248-2009.pdf)</sup> 在结局方面，将名义变量强行分成两类会损失信息，将有序因变量当作名义变量处理也会损失信息，而将其当作连续变量处理可能得出不符合现实的结论。<sup>[21](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurit%C3%A0_Kr%C3%A0lovstv%C3%AC/18%3A_Nominal_and_Ordinal_Dependent_Variables)</sup>

## 高基数变量与机器学习实践

具有许多水平的变量，如邮政编码或产品 ID，会给经典和现代方法都带来压力。在广义线性模型中，高基数协变量的虚拟编码会产生高维回归参数，容易过拟合。<sup>[23](https://link.springer.com/article/10.1007/s42081-024-00243-4)</sup> 对高基数特征进行独热编码也可能过拟合，因为特征数量爆炸式增长，其中稀有类别可能与目标偶然相关，除非使用 max_categories 上限。<sup>[24](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_target_encoder.html)</sup>

**目标编码。** CatBoost 的目标统计方法用一个数值特征替代类别值，该特征估计以该类别为条件的期望目标，E(y | x_i = x_ik)；这一机制是 category_encoders 中提供的 CatBoost 编码器和 scikit-learn 中提供的 TargetEncoder 的基础。<sup>[25](https://proceedings.neurips.cc/paper_files/paper/2018/file/14491b756b3a51daac41c24863285549-Paper.pdf)</sup> category_encoders 的 CatBoostEncoder 是目标编码的一种变体，支持时间感知编码、正则化和在线学习，其文档警告在可能发生数据泄漏时要消除数据泄漏（例如通过打乱）。<sup>[26](http://contrib.scikit-learn.org/category_encoders/catboost.html)</sup> 在跨 lasso、随机森林、梯度提升、k 近邻和支持向量机的大型基准测试中，针对回归、二分类和多分类数据集，正则化目标编码总体表现最好，采用 5 折交叉验证的 GLMM 编码除 SVM 外对所有算法均排名第一。<sup>[8](https://link.springer.com/article/10.1007/s00180-022-01207-6)</sup>

**原生分类分裂与嵌入。** LightGBM 应用费希尔（Fisher，1958）的方法来寻找类别上的最优分裂，这通常比独热编码表现更好，并要求类别为低于 2147483647 的非负 int32 编码；当 categorical_feature="auto" 时，它会自动检测无序 pandas 分类列，将预测时未见的类别视为缺失值，并提供 min_data_per_group 和 cat_smooth 来防止过拟合。<sup>[27](https://lightgbm.readthedocs.io/en/latest/Advanced-Topics.html)</sup> 在神经网络回归中，实体嵌入是处理分类协变量的一种流行方法，但对于高基数协变量，早停往往发生得很早，产生较差的预测模型；针对这种情况，已经提出了用于随机效应实体嵌入的循环和 Transformer 架构。<sup>[23](https://link.springer.com/article/10.1007/s42081-024-00243-4)</sup>

**编码器选择。** 指导取决于模型族和数据规模。对于线性回归、逻辑回归、神经网络和线性核 SVM 等分析型推断模型，推荐独热编码，尤其是当每水平平均样本数（ASPL）较大时。<sup>[28](https://arxiv.org/html/2401.09682)</sup> 对于随机森林、XGBoost 和 LightGBM 等基于树的模型，目标编码器表现出更优性能，尤其是当 ASPL 很大时。<sup>[28](https://arxiv.org/html/2401.09682)</sup> 当 ASPL 较小时，GLMM 编码是高性能的初始选择，但在高基数数据集上耗时。<sup>[28](https://arxiv.org/html/2401.09682)</sup> 最优编码取决于预测模型、水平数、可用数据量和具体问题，并可以通过使用平衡准确率等指标的交叉验证来选择。<sup>[29](https://www.esann.org/sites/default/files/proceedings/2025/ES2025-191.pdf)</sup> 对于非线性模型，一项基准测试发现，对于正则化随机森林、梯度提升和 SVM，独热编码优于虚拟编码，<sup>[8](https://link.springer.com/article/10.1007/s00180-022-01207-6)</sup> 而 2024 年的比较研究倾向于对基于树的模型使用目标编码器。<sup>[28](https://arxiv.org/html/2401.09682)</sup>

## 近期工具发展

工具已转向对类别的原生和监督式处理。scikit-learn 1.8 文档比较了 HistGradientBoosting 估计器处理分类特征的五种策略：丢弃它们、OneHotEncoder、OrdinalEncoder、TargetEncoder 和原生类别支持；TargetEncoder 使用从训练数据计算的目标统计量对类别编码。<sup>[10](https://scikit-learn.org/1.8/auto_examples/ensemble/plot_gradient_boosting_categorical.html)</sup> 在 scikit-learn 的具体比较示例中，丢弃类别表现最差，目标编码在测试集预测性能上表现最好。<sup>[24](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_target_encoder.html)</sup> 从 XGBoost 3.1 开始，Python 接口可以记住训练时的类别编码，并在推理和继续训练期间自动重新编码新的 dataframe 输入（pandas、cuDF、polars、pyarrow、modin）；在 Python 接口之外，用户必须保持训练和测试中的变换流水线一致。<sup>[11](https://xgboost.readthedocs.io/en/stable/tutorials/categorical.html)</sup> category_encoders 库已发展到二十多种编码策略，包括目标、CatBoost、证据权重、詹姆斯-斯坦、M估计、GLMM、计数、分位数、汇总、格雷和 RankHot 编码器。<sup>[30](https://joss.theoj.org/papers/10.21105/joss.10645.pdf)</sup> 一项 2025 年研究发现，以不同方式编码分类变量可能引入偏差，并建议对所有分类变量使用相同编码以减少分布外偏差。<sup>[29](https://www.esann.org/sites/default/files/proceedings/2025/ES2025-191.pdf)</sup>

## 常见陷阱与解释

**参考水平依赖性。** 在虚拟编码中，虚拟变量的系数是相对于参考组的，因此改变参考水平会改变报告的系数（尽管不改变模型拟合）。<sup>[5](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)</sup><sup> • </sup><sup>[20](https://cscu.cornell.edu/wp-content/uploads/catvars.pdf)</sup>

**静默数值强制转换。** R 通常假定包含数值的变量应被视为数字，因此类别的数值编码会导致令人困惑的错误；推荐做法是在 R 中始终用词语而不是数字来描述类别。<sup>[2](https://tuos-bio-data-skills.github.io/intro-stats-book/data-variables.html)</sup> 有序编码还施加任意顺序，树模型将其视为数值：scikit-learn 的 HistGradientBoostingRegressor 将数值特征每个特征分成 256 个箱，因此不相关的类别可能被分到一起，流水线可能欠拟合；而目标编码值则按与目标的边际关联进行统计排序。<sup>[24](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_target_encoder.html)</sup>

**泄漏与稀有类别。** 目标式编码器使用结局，因此在可能发生数据泄漏时必须消除这种泄漏。<sup>[26](http://contrib.scikit-learn.org/category_encoders/catboost.html)</sup> 没有上限时，对高基数特征进行独热编码可能过拟合，因为稀有类别会偶然与目标相关。<sup>[24](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_target_encoder.html)</sup>

**李克特问题。** 关于李克特式有序题项是否可作为数值处理，来源意见不一。一份参考认为有序水平不应作为数值处理，因为“非常同意”和“中立”可能平均不出“同意”，并且李克特题项数据在大多数情况下是有序的。<sup>[31](https://www.rcompanion.org/handbook/C_01.html)</sup> 一篇方法学综述指出，具有许多类别的有序变量有时被当作数值处理，偏差有限，尤其是当类别数至少为 11 时（引用 Wu 和 Leung（Wu and Leung）2017），而 2024 年的一篇测量论文建议计数和李克特量表数据可以作为连续量分析，或使用泊松、负二项或有序逻辑模型离散分析。<sup>[3](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)</sup><sup> • </sup><sup>[15](https://www.mdpi.com/2624-8611/5/2/18)</sup>

## 测量类型学的历史与批评

20 世纪 40 年代初，哈佛大学（Harvard University）心理学家 S. S. 史蒂文斯（S. S. Stevens）为心理物理测量尺度的层级发明了名义、有序、等距和比率这些标签，并根据哪些尺度类型适合哪些方法对统计方法进行了分类。<sup>[32](https://faculty.ucmerced.edu/jvevea/classes/290_21/readings/week%208/Velleman%20and%20Wilkinson%201993.pdf)</sup> 公认的观点既包括这一分类，也包括一套关于基于容许变换的测量推断的规定。<sup>[33](https://www.cambridge.org/core/journals/philosophy-of-science/article/on-measurement-scales-neither-ordinal-nor-interval/BE9D7DBF7558EA12221776D5E995516A)</sup>

该框架招致持续批评。史蒂文斯的分类被描述为心理与教育测量中最具争议却又最有韧性的观点之一，<sup>[15](https://www.mdpi.com/2624-8611/5/2/18)</sup> 而史蒂文斯式的变量刻画并不被统计学家普遍接受，部分原因是它忽略了名义变量的偏序以及比率变量是计数还是比例等区分。<sup>[6](https://support.sas.com/resources/papers/proceedings09/248-2009.pdf)</sup> 2024 年的一项重新评估得出结论：当前的尺度类型概念用处有限，应在心理测量话语和教学中占据较小角色，理由是尺度类型只能在充分发展的理论和实验背景下确立。<sup>[15](https://www.mdpi.com/2624-8611/5/2/18)</sup> 一篇《科学哲学》（Philosophy of Science）文章提出用研究者的信念来对有序/等距区分作认识论刻画，认为这一区分过于粗粒度：一个尺度要有序，必须存在相当强的信念，因此现实研究者的尺度不太可能位于连续谱的任一极端。<sup>[33](https://www.cambridge.org/core/journals/philosophy-of-science/article/on-measurement-scales-neither-ordinal-nor-interval/BE9D7DBF7558EA12221776D5E995516A)</sup> 与此相对，实践参考仍然认为变量类型决定哪种统计分析有效，并且通常宜在变量有资格达到的最高测量水平上处理变量，因为更高水平保留更多信息并提供更多分析选项。<sup>[31](https://www.rcompanion.org/handbook/C_01.html)</sup>

## References

1. [Categorical data — pandas documentation](https://pandas.pydata.org/docs/user_guide/categorical.html)
2. [Data and variables (Introductory Biostatistics with R)](https://tuos-bio-data-skills.github.io/intro-stats-book/data-variables.html)
3. [A short overview of variable types and how to choose them (BJPsych Advances)](https://www.cambridge.org/core/journals/bjpsych-advances/article/short-overview-of-variable-types-and-how-to-choose-them/7F8E965967B15CBAE020878DDDE23280)
4. [What is the difference between categorical, ordinal and interval variables? (UCLA OARC)](https://stats.oarc.ucla.edu/other/mult-pkg/whatstat/what-is-the-difference-between-categorical-ordinal-and-interval-variables/)
5. [Dummy Variables — MATLAB & Simulink (MathWorks)](https://www.mathworks.com/help/stats/dummy-indicator-variables.html)
6. [Learning When to Be Discrete: Continuous vs. Categorical Predictors (SAS Global Forum 2009)](https://support.sas.com/resources/papers/proceedings09/248-2009.pdf)
7. [Features — LightGBM documentation](https://lightgbm.readthedocs.io/en/latest/Features.html)
8. [Regularized target encoding outperforms traditional methods in supervised machine learning with high cardinality features (Computational Statistics)](https://link.springer.com/article/10.1007/s00180-022-01207-6)
9. [R: Factors (official R base documentation)](https://search.r-project.org/R/refmans/base/html/factor.html)
10. [Categorical Feature Support in Gradient Boosting — scikit-learn 1.8 documentation](https://scikit-learn.org/1.8/auto_examples/ensemble/plot_gradient_boosting_categorical.html)
11. [Categorical Data — XGBoost documentation](https://xgboost.readthedocs.io/en/stable/tutorials/categorical.html)
12. [Types of Variables and Commonly Used Statistical Designs (StatPearls, NCBI Bookshelf)](https://www.ncbi.nlm.nih.gov/books/NBK557882/)
13. [Survey on categorical data for neural networks (Journal of Big Data)](https://link.springer.com/article/10.1186/s40537-020-00305-w)
14. [The Structure of Data (Statistics LibreTexts)](https://stats.libretexts.org/Courses/Northern_Illinois_University/Data_and_the_Modern_World/05%3A_The_Nature_of_Data/5.03%3A_The_Structure_of_Data)
15. [Scale Type Revisited: Some Misconceptions, Misinterpretations, and Recommendations (Measurement, MDPI, 2024)](https://www.mdpi.com/2624-8611/5/2/18)
16. [Kinds of variables (Handbook of Biological Statistics)](http://biostathandbook.com/variabletypes.html)
17. [Using Categorical Variables in Regression (IBM SPSS)](https://public.dhe.ibm.com/software/analytics/spss/support/Stats/Docs/Statistics/Articles/catreg1.htm)
18. [Working with Categorical Predictors (Applied Machine Learning for Tabular Data, Kuhn & Johnson)](https://aml4td.org/chapters/categorical-predictors.html)
19. [Coding Systems for Categorical Variables in Regression Analysis (UCLA OARC)](https://stats.oarc.ucla.edu/spss/faq/coding-systems-for-categorical-variables-in-regression-analysis/)
20. [Categorical Variables in Regression: Dummy and Effect Coding (Cornell Statistical Consulting Unit)](https://cscu.cornell.edu/wp-content/uploads/catvars.pdf)
21. [Nominal and Ordinal Dependent Variables (Statistics LibreTexts)](https://stats.libretexts.org/Courses/Knox_College/Linear_Models_and_Rurit%C3%A0_Kr%C3%A0lovstv%C3%AC/18%3A_Nominal_and_Ordinal_Dependent_Variables)
22. [Agresti. An Introduction to Categorical Data Analysis (Wiley)](https://onlinelibrary.wiley.com/doi/book/10.1002/0471249688)
23. [High-cardinality categorical covariates in network regressions (Japanese Journal of Statistics and Data Science)](https://link.springer.com/article/10.1007/s42081-024-00243-4)
24. [Comparing Target Encoder with Other Encoders — scikit-learn documentation](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_target_encoder.html)
25. [CatBoost: unbiased boosting with categorical features (NeurIPS 2018)](https://proceedings.neurips.cc/paper_files/paper/2018/file/14491b756b3a51daac41c24863285549-Paper.pdf)
26. [CatBoost Encoder — Category Encoders documentation](http://contrib.scikit-learn.org/category_encoders/catboost.html)
27. [Advanced Topics — LightGBM documentation](https://lightgbm.readthedocs.io/en/latest/Advanced-Topics.html)
28. [Comparative Study on the Performance of Categorical Variable Encoders in Classification and Regression Tasks (arXiv, 2024)](https://arxiv.org/html/2401.09682)
29. [Encoding Matters: Impact of Categorical Variable Encoding on Performance and Bias (ESANN 2025)](https://www.esann.org/sites/default/files/proceedings/2025/ES2025-191.pdf)
30. [Category Encoders: a scikit-learn-contrib package of transformers for encoding categorical data (JOSS)](https://joss.theoj.org/papers/10.21105/joss.10645.pdf)
31. [Types of Variables (R Handbook)](https://www.rcompanion.org/handbook/C_01.html)
32. [Velleman & Wilkinson (1993). Nominal, Ordinal, Interval, and Ratio Typologies Are Misleading](https://faculty.ucmerced.edu/jvevea/classes/290_21/readings/week%208/Velleman%20and%20Wilkinson%201993.pdf)
33. [On Measurement Scales: Neither Ordinal Nor Interval? (Philosophy of Science, Cambridge Core)](https://www.cambridge.org/core/journals/philosophy-of-science/article/on-measurement-scales-neither-ordinal-nor-interval/BE9D7DBF7558EA12221776D5E995516A)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026; Oct 21, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistics and probability — overview and reference

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/categorical-variable

English original: https://www.edgepedia.org/categorical-variable
