zoukankan      html  css  js  c++  java
  • LableEncoder编码

    from sklearn.preprocessing import LabelEncoder
    #举例对属性job进行LE编码
    LE = LabelEncoder()
    label = LE.fit_transform(train['job'])
    print(label)
    sorted_job = sorted(train['job'].value_counts().keys())
    for i in range(12):
        print(sorted_job[i],':',i)
    
    [4 9 0 ... 1 2 4]
    admin. : 0
    blue-collar : 1
    entrepreneur : 2
    housemaid : 3
    management : 4
    retired : 5
    self-employed : 6
    services : 7
    student : 8
    technician : 9
    unemployed : 10
    unknown : 11
    

    LabelEncoder编码是按照值的字符顺序来标号的。比如a开头的字符串对应的编码是0

  • 相关阅读:
    python
    python
    python
    python
    python
    python
    python
    python
    人生苦短,我用python,为什么选择python,python简介
    Mysql-查询
  • 原文地址:https://www.cnblogs.com/jiaxinwei/p/13907346.html
Copyright © 2011-2022 走看看