文章目录 1 介绍LabelEncoder 2 作用 3 代码举例 4 代码举例2 1 介绍LabelEncoder 在训练模型之前,需要对数据进行处理,比如说分类,进行类别编号。 举例:把“男”、“女”编号为“0”和“1”。 2 作用 把 n 个类别编码为 0 ~ n-1 之间的整数(包含0和n - 1) 3 代码举例 导包 import numpy as np import pandas as pd from sklearn import preprocessing 代码 sex = pd.Series(["male", "femal