sklearn.preprocessing.LabelEncoder
来源:互联网 发布:淘宝母婴店名字 编辑:程序博客网 时间:2024/05/18 01:11
sklearn.preprocessing.LabelEncoder():标准化标签,将标签值统一转换成range(标签值个数-1)范围内
以数字标签为例:
[python] view plain copy
In [1]: from sklearn import preprocessing ...: le = preprocessing.LabelEncoder() ...: le.fit([1,2,2,6,3]) ...: Out[1]: LabelEncoder()
获取标签值
[python] view plain copy
In [2]: le.classes_ Out[2]: array([1, 2, 3, 6])
将标签值标准化
[python] view plain copy
In [3]: le.transform([1,1,3,6,2]) Out[3]: array([0, 0, 2, 3, 1], dtype=int64)
将标准化的标签值反转
[python] view plain copy
In [4]: le.inverse_transform([0, 0, 2, 3, 1]) Out[4]: array([1, 1, 3, 6, 2])
非数字型标签值标准化:
[python] view plain copy
In [5]: from sklearn import preprocessing ...: le =preprocessing.LabelEncoder() ...: le.fit(["paris", "paris", "tokyo", "amsterdam"]) ...: print('标签个数:%s'% le.classes_) ...: print('标签值标准化:%s' % le.transform(["tokyo", "tokyo", "paris"])) ...: print('标准化标签值反转:%s' % le.inverse_transform([2, 2, 1])) ...: 标签个数:['amsterdam' 'paris' 'tokyo'] 标签值标准化:[2 2 1] 标准化标签值反转:['tokyo' 'tokyo' 'paris']
阅读全文
0 0
- sklearn.preprocessing.LabelEncoder
- sklearn.preprocessing.LabelEncoder
- sklearn.preprocessing.LabelEncoder和onehotencoder
- sklearn.preprocessing中 LabelEncoder 和 OneHotEncoder区别
- sklearn preprocessing
- sklearn-Preprocessing
- Sklearn中LabelEncoder与OneHotEncoder
- Sklearn-preprocessing.PolynomialFeatures
- sklearn.preprocessing.PolynomialFeatures 用法
- sklearn.preprocessing.PolynomialFeatures
- sklearn.preprocessing.Binarizer
- sklearn.preprocessing.OneHotEncoder
- sklearn.preprocessing.Imputer
- sklearn.preprocessing.Normalizer
- sklearn.preprocessing.LabelBinarizer
- sklearn.preprocessing.MultiLabelBinarizer
- PYTHON-sklearn.preprocessing
- 使用sklearn之LabelEncoder将Label标准化
- 计算机视觉技术路径
- JVM中Java对象的创建
- POI使用详解 Apache POI使用详解
- GAN原理,优缺点、应用总结
- 最新网狐荣耀版棋牌源码、编译和搭建教程
- sklearn.preprocessing.LabelEncoder
- 500 G JAVA视频网盘分享
- 工业相机相关知识
- java第一课
- QT窗口退出
- HDU
- mac终端(terminal)常见的快捷键
- 五层协议体系结构
- java异常catch