Applying different transformations to different columns

ColumnTransformer routes subsets of columns to appropriate transformers and joins their outputs into one feature matrix.

ColumnTransformer in practice

Scale age and one-hot encode city. Unselected columns are dropped by default, so explicitly route a newly introduced key field.

中文

同一张表怎样分别处理数字列与类别列?

ColumnTransformer 将列子集交给对应变换器,然后拼接成一个供模型使用的矩阵。

ColumnTransformer 应用实例

年龄用缩放器、城市用独热编码。未选中的列默认丢弃,新增的关键字段应显式纳入规则。

References / 参考来源

Keep reading / 继续阅读