当前位置:网站首页>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】2034. 股票价格波动(思路+题解)双map
- CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )
- CLUSTER DAY04 (Block Storage Use Cases, Distributed File Systems, Object Storage)
- 查看内核版本和发行版版本
- 阿里巴巴规范之POJO类中布尔类型的变量都不要加is前缀详解
- window7开启远程桌面功能
- CLUSTER DAY01 (Introduction to cluster and LVS, LVS-NAT cluster, LVS-DR cluster)
- 知识蒸馏Knownledge Distillation
- MySQL之函数
- TOP2 Add two numbers
猜你喜欢
HCIP Republish/Routing Policy Experiment
arcgis填坑_3
MySQL导入导出&视图&索引&执行计划
HCIP-Spanning Tree (802.1D, Standard Spanning Tree/802.1W: RSTP Rapid Spanning Tree/802.1S: MST Multiple Spanning Tree)
(2) Software Testing Theory (*Key Use Case Method Writing)
CLUSTER DAY03( Ceph概述 、 部署Ceph集群 、 Ceph块存储)
OA项目之我的审批(查询&会议签字)
CLUSTER DAY02( Keepalived热备 、 Keepalived+LVS 、 HAProxy服务器 )
ovnif摄像头修改ip
slurm cluster construction
随机推荐
配置dns服务
中国移动通信集团有限公司:业务委托书
HPC平台搭建
HCIP-BGP的选路实验
SECURITY DAY05 (Kali system, scanning and caught, SSH basic protection, service SECURITY)
Conference OA Project My Conference
HPC platform building
HCIP--交换基础
arcgis填坑_3
ETCD cluster fault emergency recovery - local data is available
HCIP BGP建邻实验
CLUSTER DAY01 (Introduction to cluster and LVS, LVS-NAT cluster, LVS-DR cluster)
ETCD containerized to build a cluster
华为防火墙-2-状态检测与会话
detectron2,手把手教你训练mask_rcnn
查看CPU和其他硬件温度的软件
【LeetCode】851.喧闹与富有(思路+题解)
buildroot setup dhcp
Record a Makefile just written
pytorch下tensorboard可视化深坑