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论文地址: ...
随机推荐
- 【weixin】微信企业号和公众号区别和关系是什么?
在移动互联网快速发展和智能手机普遍应用的时代环境下,随着微信平台应用不断扩大和微信用户的迅速增加,微信公众号运营也有了很大的发展,企业.机构和个人纷纷迈入微信公众号运营的行列.微信公众号就是在微信公众 ...
- vue项目使用openlayers来添加地图标注,标注样式设置的简要模板
先把代码贴出来,注释以后有时间再写(需要留意一下这里图标的引入方式,函数内相同路径无法找到图片) import sk from "../../assets/img/home/sk-activ ...
- 【Swift后台】环境安装
macOS 在macOS上使用Vapor,需要Xcode 9.3或更高版本.Swift 4.1或更高版本.安装还需要Homebrew命令. 检查Swift版本: swift --version Vap ...
- PyCharm 创建指定版本的 Django (超详细图解)
最近在学习胡阳老师(the5fire)的<Django企业级开发实战>,想要使用pycharm创建django项目时,在使用virtualenv创建虚拟环境后,在pycharm内,无论如何 ...
- linux命令详解——xargs
1. 简介 之所以能用到这个命令,关键是由于很多命令不支持|管道来传递参数,而日常工作中有有这个必要,所以就有了xargs命令,例如: find /sbin -perm +700 |ls -l ...
- 利用openssl完成自签发证书步骤--精华版
#CentOS 7 CA目录 cd /etc/pki/CA #建立 demoCA 目录结构mkdir -p ./demoCA/{private,newcerts}touch ./demoCA/inde ...
- Python中文转为拼音
# -*- coding: utf-8 -*-import sys def openTable(): f = open('gb-pinyin.table', 'r') table = f.read() ...
- 8.2.ZooKeeper应用场景
7.ZooKeeper应用举例 为了方便大家理解ZooKeeper,在此就给大家举个例子,看看ZooKeeper是如何实现的他的服务的,我以ZooKeeper提供的基本服务分布式锁为例. 7.1 分布 ...
- 关于C++跨平台
问题:C++是怎么跨平台的呢? 答: 因为支持C++语言的各个平台的架构不同(比如CPU能够处理的指令集不一样),所以一份C++源代码要想在另一个操作系统平台上执行,就必须用该平台相对应的C++代码编 ...
- Linux配置JDK环境
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-co ...