当前位置:网站首页>【sklearn】sklearn.preprocessing.LabelEncoder
【sklearn】sklearn.preprocessing.LabelEncoder
2022-07-25 08:48:00 【Enzo wants to smash the computer】
sklearn.preprocessing.LabelEncoder
effect : Convert non numeric labels to numeric labels
First, let's see what the official said : Official address
- Encode target labels with value between 0 and n_classes-1.
- take Value of target label Encoded as 1 To n-1, ( altogether n A classification )
- This transformer should be used to encode target values, i.e. y, and not the input X.
- This transformation Should be applied to code Value of label , such as y, Instead of encoding input values , such as x
give an example
import numpy as np
import pandas as pd
import sklearn.preprocessing as preprocessing
city = pd.Series(["paris", "paris", "tokyo", "amsterdam"])
le = preprocessing.LabelEncoder()
le.fit(city)
list(le.classes_) # Check the category after label weight removal
# ['amsterdam', 'paris', 'tokyo']
# Tag value conversion , It can be understood as , Map non numeric labels to numeric labels
le.transform(city)
# Output is : array([1, 1, 2, 0])
# Reverse transformation , Restore digital labels to non digital labels
list(le.inverse_transform([1, 1, 2, 0]))
# ['tokyo', 'tokyo', 'paris']
What is involved above 3 A way :
le.fit(df): Remove the weight of the label , Generate categories , And encoded as a digital labelle.transform(df): Map all the original data labels to On the digital labelle.inverse_transform(list): Put the number tag Inverse conversion to Non numeric label
边栏推荐
- Wechat reservation applet graduation design of applet completion works (1) development outline
- js弹出式城市筛选组件匹配手机移动端
- 51单片机内部外设:串口通信
- @Autowired的使用
- Implementation of depth first and breadth first traversal of binary tree
- Graduation project of wechat small program ordering system of small program completion works (4) opening report
- A page widgetization practice
- 51 single chip microcomputer controls nixie tube display
- QA robot sequencing model
- 游戏外挂怎么做?
猜你喜欢

YOLOV5环境配置

js弹出式城市筛选组件匹配手机移动端
![[Sesame Street family] & Bert Bart Roberta](/img/ff/c685065cd413bd4cffd996fd9afeaa.png)
[Sesame Street family] & Bert Bart Roberta

Django4.0 + Web + MySQL5.7 实现简单登录操作

How to do the game plug-in?

Idea2021 failed to start. Could not find main class com/intellij/idea/main

QA robot sequencing model

Talk about your transformation test development process

@Implementation principle of Autowired annotation

51单片机外设篇:蜂鸣器
随机推荐
51 MCU peripherals: Motor
Implementation of depth first and breadth first traversal of binary tree
C语言实现二叉平衡树
Record the process of two multi terminal troubleshooting
When crontab scheduled task executes jar through script, it encounters a pit where jar package execution is invalid
Graduation design of wechat small program ordering system of small program completion works (5) assignment
PHP gets all child nodes under any parent node of the tree structure
The international summit osdi included Taobao system papers for the first time, and end cloud collaborative intelligence was recommended by the keynote speech of the conference
js触屏小游戏源码冰雪之旅
Wechat sports field reservation of the finished works of the applet graduation project (4) opening report
@Differences between requestparam, @pathparam, @pathvariable and other annotations (use of some annotations)
[graduation project] cinema booking management system based on micro Service Framework
富文本样式文字图片处理
Mongodb database
LeetCode·83双周赛·6129.全0子数组的数目·数学
Wechat sports ground reservation applet graduation design of applet completion works (2) applet function
Network solutions for Alibaba cloud services
efcore在Saas系统下多租户零脚本分表分库读写分离解决方案
JD cloud and Forrester consulting released a hybrid cloud report that cloud Nativity has become a new engine driving industrial development
这是我见过写得最烂的Controller层代码...