You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure ML Studio中实现Label Encoding(标签编码)

在Azure ML Studio中实现Label Encoding(标签编码)

Azure ML Studio没有原生的Label Encoding模块,但可以通过Execute Python Script模块快速实现,步骤如下:

  1. 将「Execute Python Script」模块拖入你的工作流,连接目标数据集作为输入
  2. 替换模块内的默认代码为以下逻辑,把target_cols替换成你需要编码的20列列名:
    import pandas as pd
    from sklearn.preprocessing import LabelEncoder
    
    def azureml_main(df = None, df2 = None):
        # 替换为你的20个分类列名
        target_cols = ["Column1", "Column2", ..., "Column20"]
        
        encoder = LabelEncoder()
        for col in target_cols:
            df[col] = encoder.fit_transform(df[col])
        
        return df,
    
  3. 运行工作流即可得到你想要的Label Encoding效果——将分类值映射为连续整数(比如RL→1、RM→2)

示例效果对比

  • 原始数据:
    Column1
    RL
    RL
    RM
    RL
    RM
    RM
    
  • 处理后结果:
    Column1
    1
    1
    2
    1
    2
    2
    

内容的提问来源于stack exchange,提问作者Sunag

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 19:57:25