Tree-based Model 如何处理categorical variable
categorical variable 分为 order variale 和 non-order variable,其中order variable直接使用sklearn.preprocess.LabelEncoder是最好的处理方法。对于order variable的处理方法主要在于是否使用one-hot encoding。在这篇quora answer (author: Clem Wang)中给出了其它的处理方法:
One can try a few other approaches:
- look at how the response variable responds to the categorical values and try to group them.
- Find another ML algorithm that works better with categorical features or with one-hot encoding and use that to train a submodel that just uses the categorical features. Then replace the categorical feature with a probability score. For instance, use a Logistic Regression on the hot-encoded values.
- Try to combine the categorical feature with some other features.
- Build N xgboost classifiers, one for each category.
This may require playing around with the data a bit. Plotting the data may help you see patterns that you didn't know that were there.
这篇博客对于在xgboost中使用one-hot给出了一个总体结论:
总结起来的结论,大至两条:
- 1.对于类别有序的类别型变量,比如age等,当成数值型变量处理可以的。对于非类别有序的类别型变量,推荐one-hot。但是one-hot会增加内存开销以及训练时间开销。
- 2.类别型变量在范围较小时(tqchen给出的是[10,100]范围内)推荐使用
其他相关的资料
comment:re sklearn -- integer encoding vs 1-hot
Tree-based Model 如何处理categorical variable的更多相关文章
- A Complete Tutorial on Tree Based Modeling from Scratch (in R & Python)
A Complete Tutorial on Tree Based Modeling from Scratch (in R & Python) MACHINE LEARNING PYTHON ...
- 10X genomics|cell base|in-vivo based|model organisms|SBI|
生命组学-药物基因组学 精准医学的内容有个人全基因组测序,移动可穿戴设备,它可以实时监测,深度学习模型预测疾病,对疾病预测做到有效.安全和可控. 药物基因组学就是研究疾病.化合物和靶点之间的关系,关键 ...
- 含有分类变量(categorical variable)的逻辑回归(logistic regression)中虚拟变量(哑变量,dummy variable)的理解
版权声明:本文为博主原创文章,博客地址:,欢迎大家相互转载交流. 使用R语言做逻辑回归的时候,当自变量中有分类变量(大于两个)的时候,对于回归模型的结果有一点困惑,搜索相关知识发现不少人也有相同的疑问 ...
- QT目录模型QDirModel的使用(一个model同时连接tree,list,table)
3#include <QApplication>#include <QAbstractItemModel>#include <QAbstractItemView># ...
- Spark MLlib - Decision Tree源码分析
http://spark.apache.org/docs/latest/mllib-decision-tree.html 以决策树作为开始,因为简单,而且也比较容易用到,当前的boosting或ran ...
- (转)Decision Tree
Decision Tree:Analysis 大家有没有玩过猜猜看(Twenty Questions)的游戏?我在心里想一件物体,你可以用一些问题来确定我心里想的这个物体:如是不是植物?是否会飞?能游 ...
- Physically Based Shader Development for Unity 2017 Develop Custom Lighting Systems (Claudia Doppioslash 著)
http://www.doppioslash.com/ https://github.com/Apress/physically-based-shader-dev-for-unity-2017 Par ...
- Codeforces 379F New Year Tree
F. New Year Tree time limit per test2 seconds memory limit per test256 megabytes You are a programme ...
- 谣言检测()——《Debunking Rumors on Twitter with Tree Transformer》
论文信息 论文标题:Debunking Rumors on Twitter with Tree Transformer论文作者:Jing Ma.Wei Gao论文来源:2020,COLING论文地址: ...
随机推荐
- 移动端真机debug调试神器 vConsole学习(二)之实战
项目中实际使用 在项目中实际使用的时候发现还是有很多问题的 最初使用方式 <script src="vconsole.min.js"></script> ...
- JS基础_for循环练习3
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Mongoose 使用Node操作MongoDB
Mongoose好处 可以为文档创建一个模式结构(Schema) 可以对模型中的对象/文档进行验证 数据可以通过类型转换转换为对象模型 可以使用中间件来应用业务逻辑挂钩 比Node原生的MongoDB ...
- Windows 10 安装FileZilla Server
在windows 10本机安装了FileZilla Server 本机用FilleZilla Client连接localhost或者192.168.0.197 port 21 都可以连通,但是在同 ...
- linux常用命令(4)
linux常用命令(4) --- Vim编辑器与Shell命令脚本 如何使用vim编辑器来编写文档.配置主机名称.网卡参数以及yum仓库: 通过vim编辑器将Linux命令放入合适的逻辑测试语句(if ...
- 第十章、random模块
目录 第十章.random模块 第十章.random模块 #随机生成0-1之间的小数 import random print(random.random()) print(random.randint ...
- 第九章、import 和from ...import
目录 第九章.import 和from ...import 一.import和 from ...import ... 二.import模块名 第九章.import 和from ...import 一. ...
- 2019-2020-1 20199319《Linux内核原理与分析》第一周作业
一.Linux系统简介 通过实验一了解了Linux 的历史,Linux与windows之间的区别以及学习Linux的方法.因为一直用的都是windows系统,习惯了图形界面,而Linux是通过输入命令 ...
- IntelliJ IDEA安装后几个重要的目录及配置文件讲解
本文大概记录了IntelliJ IDEA安装之后比较重要的目录和几个核心文件 重要的安装目录 安装完之后的bin目录大致如下 IntelliJ IDEA 的安装目录并不复杂,上图为最常改动的 bin ...
- iOS View的一些操作定义为宏
#define ViewOf(__View__,__TAG__) [__View__ viewWithTag:__TAG__]#define LabelOf(__View__,__TAG__) ((U ...