首页 > 解决方案 > scikit-learn 的标签编码序数和整数

问题描述

我有不同类型的列要编码:(a)名义值(字符串),(b)序数值(字符串)和(c)序数值(数字),它们是从“优秀”等资格手动映射(使用映射)的, 'Poor' 等,因为没有按字母顺序正确分配值。

知道 LabelEncoder 的输出是一列整数,我应该 LabelEncode 组 b 和组 c 还是只组 b?在这里,我提供所有组的示例。

A组(OneHotEncoding)

GarageType: Garage location

       2Types   More than one type of garage
       Attchd   Attached to home
       Basment  Basement Garage
       BuiltIn  Built-In (Garage part of house - typically has room above garage)
       CarPort  Car Port
       Detchd   Detached from home
       NA   No Garage

b组(标签编码)

GarageFinish: Interior finish of the garage

       Fin  Finished
       RFn  Rough Finished  
       Unf  Unfinished
       NA   No Garage

c组(映射)

GarageQual: Garage quality

       Ex   Excellent
       Gd   Good
       TA   Typical/Average
       Fa   Fair
       Po   Poor
       NA   No Garage

我正在正确映射 C 组的值,我的问题是我必须应用 LabelEncoder,即使它们是整数。

标签: pythonencodingscikit-learn

解决方案


推荐阅读