当前位置:网站首页>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()
对标签进行了编码,转换成了对应数值。
本文原载于我的简书
边栏推荐
- vnc remote desktop installation (available for personal testing on 2021-10-20)
- iptables的状态
- 知识蒸馏Knownledge Distillation
- SECURITY DAY06 ( iptables firewall, filter table control, extended matching, typical application of nat table)
- 【LeetCode】306.累加数(思路+题解)
- Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-2
- 查看CPU和其他硬件温度的软件
- FusionCompute8.0.0实验(0)CNA及VRM安装(2280v2)
- Arcgis小工具_实现重叠分析
- 类的定义、类的继承以及super的使用
猜你喜欢
SECURITY DAY04( Prometheus服务器 、 Prometheus被监控端 、 Grafana 、 监控数据库)
lvm 多盘挂载,合并使用
MySQl进阶之索引结构
My meeting of the OA project (meeting seating & review)
使用路由器DDNS功能+动态公网IP实现外网访问(花生壳)
AUTOMATION DAY07( Ansible Vault 、 普通用户使用ansible)
OA项目之待开会议&历史会议&所有会议
AUTOMATION DAY07 (Ansible Vault, ordinary users use ansible)
CLUSTER DAY01 (Introduction to cluster and LVS, LVS-NAT cluster, LVS-DR cluster)
HCIP OSPF动态路由协议
随机推荐
华为防火墙-6
slurm集群搭建
HCIP-Spanning Tree (802.1D, Standard Spanning Tree/802.1W: RSTP Rapid Spanning Tree/802.1S: MST Multiple Spanning Tree)
windows10安全中心显示“修正未完成”
Class definition, class inheritance, and the use of super
会议OA项目之我的会议
Solve win10 installed portal v13 / v15 asked repeatedly to restart problem.
SECURITY DAY02( Zabbix报警机制 、 Zabbix进阶操作 、 监控案例)
Threatless Technology-TVD Daily Vulnerability Intelligence-2022-8-2
HCIP MPLS/BGP综合实验
HCIP BGP建邻实验
智能合约 ——— app评分合约
Raspberry Pi set static IP address
My approval of OA project (inquiry & meeting signature)
iptables入门
FusionCompute8.0.0实验(1)CNA及VRM安装
SECURITY DAY04( Prometheus服务器 、 Prometheus被监控端 、 Grafana 、 监控数据库)
My meeting of the OA project (meeting seating & review)
HCIA experiment
ETCD cluster fault emergency recovery - local data is available