如何处理类别变量

https://www.analyticsvidhya.com/blog/2015/11/easy-methods-deal-categorical-variables-predictive-modeling/

1、Convert to number

(1)Label Encoder

(2)Convert numeric bins to number

2、Combine Levels

(1)Using Business Logic: It is one of the most effective method of combining levels. It makes sense also to combine similar levels into similar groups based on domain or business experience.This will reduce the number of levels and improve the model performance also.

(2)Using frequency or response rate: In such cases, we combine levels by considering the frequency distribution or response rate.

3、Dummy Coding

Dummy coding is a commonly used method for converting a categorical input variable into continuous variable. ‘Dummy’, as the name suggests is a duplicate variable which represents one level of a categorical variable. Presence of a level is represent by 1 and absence is represented by 0. For every level present, one dummy variable will be created. Look at the representation below to convert a categorical variable using dummy variable.

猜你喜欢

转载自blog.csdn.net/Gin077/article/details/81082551