当前位置:网站首页>LabelEncoder和LabelBinarizer的区别
LabelEncoder和LabelBinarizer的区别
2022-08-11 05:35:00 【Pr4da】
LabelBinarizer
import numpy as np
from sklearn.preprocessing import LabelBinarizer
lb = LabelBinarizer()
a = np.array([1,2,3,2,5,6,6])
b = lb.fit_transform(a)
print(b)
输出为:
[[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 1 0 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
[0 0 0 0 1]]
LabelBinarizer
它将标签转换成了one-hot的形式。
LabelEncoder
import numpy as np
from sklearn.preprocessing import LabelBinarizer
le = LabelEncoder()
a = np.array([1,2,3,2,5,6,6])
e = le.fit_transform(a)
print(e)
输出为:
[0 1 2 1 3 4 4]
LabelEncoder()
对标签进行了编码,转换成了对应数值。
本文原载于我的简书
边栏推荐
- 【LeetCode】851.喧闹与富有(思路+题解)
- ETCD cluster fault emergency recovery - to recover from the snapshot
- 知识蒸馏Knownledge Distillation
- uboot sets the default bootdelay
- 核方法 Kernel method
- iptables nat
- HCIP BGP建邻实验
- OA项目之我的审批(查询&会议签字)
- CLUSTER DAY04 (Block Storage Use Cases, Distributed File Systems, Object Storage)
- FusionCompute8.0.0 实验(2)虚拟机创建
猜你喜欢
随机推荐
buildroot setup dhcp
阿里巴巴规范之POJO类中布尔类型的变量都不要加is前缀详解
How Xshell connects to a virtual machine
uboot设置默认的bootdelay
buildroot设置dhcp
配置dns服务
Numpy_备注
防火墙-0-管理地址
本地yum源搭建
buildroot嵌入式文件系统中vi显示行号
OA项目之待开会议&历史会议&所有会议
升级到Window11体验
HCIP OSPF dynamic routing protocol
HCIA知识复习
HCIP MPLS/BGP综合实验
查看可执行文件依赖的库ldd
Es common operations and classical case
The ramdisk practice 1: the root file system integrated into the kernel
slurm集群搭建
MySQL导入导出&视图&索引&执行计划