python - 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,即使它们是整数。
解决方案
推荐阅读
- c++ - nlohmann 和复制地图
- excel - 数据透视表项目 - 避免使用许多导致 Excel 崩溃的 INDEX 和 MATCH 函数
- node.js - 等待KafkaJS中的领导选举
- apache-kafka - 如何定期而不是连续地读取/轮询 kafka 消息
- html - 如何为 ID 中的类自定义 CSS
- css - 如何将 CSS 从“::before”选择器移动到 React?
- java - Spring Boot 卡夫卡监听器
- sql - SQL Server - 计算销售概览的每周目标值与实际值
- python - 通过shell脚本.bat文件自动连接到oracle的python脚本时出错
- r - 将长格式转换为宽格式