SoFunction
Updated on 2024-12-19

An explanation of LabelEncoder and OneHotEncoder in python data processing.

An explanation of LabelEncoder and OneHotEncoder in python data processing.

Updated July 11, 2018 09:08:31 by hiptonese
Today I'd like to share with you a detailed explanation of LabelEncoder and OneHotEncoder in python data processing, with good reference value, I hope it will help you. Together follow the editor over to see it

As shown below:

# Simply put LabelEncoder is a numbering system for discrete numbers or text.
from  import LabelEncoder
le = LabelEncoder()
([1,5,67,100])
([1,1,100,67,5])
exports: array([0,0,3,2,1])

The #OneHotEncoder is used to dimensionally expand the data representing the classification:
from  import OneHotEncoder
ohe = OneHotEncoder()
([[1],[2],[3],[4]])
([2],[3],[1],[4]).toarray()
exports:[ [0,1,0,0] , [0,0,1,0] , [1,0,0,0] ,[0,0,0,1] ]

Above this piece of python data processing in the LabelEncoder and OneHotEncoder details is all I have shared with you, I hope to give you a reference, and I hope you support me more.

  • python
  • LabelEncoder
  • OneHotEncoder

Related articles

  • How to copy excel templates and retain table styles in python?

    This article introduces the python of how to copy excel templates and retain the form style issues, with good reference value, I hope to help you. If there is any error or not fully considered, please do not hesitate to give advice!
    2023-06-06
  • Python implementation to get geolocation information for photos

    This article mainly for you to introduce in detail how to use Python's PIL (Python Imaging Library) library to achieve from the JPEG image to get the latitude and longitude information, you can refer to the need to
    2023-05-05
  • python implementation of chat applet

    This article is mainly for you to introduce in detail the realization of python chat applet, with certain reference value, interested partners can refer to it!
    2018-03-03
  • Convenient way to extract properties of python imported packages

    Today I'm going to share with you a convenient way to extract the properties of python import packages, with good reference value, I hope it will help you. Together follow the editor over to see it
    2018-10-10
  • Python Performance Optimization Tips Summary

    Code optimization is the ability to make a program run faster, which is to make a program run more efficiently without changing the results of the program. According to the 80/20 principle, refactoring, optimizing, extending, and documenting a program usually consumes 80% of the work. Optimization usually consists of two aspects: reducing the size of the code and improving the efficiency of the code.
    2016-11-11
  • A python implementation of solving the problem of arranging and combining elements in a list

    This article gives you to share the use of python's built-in module to solve the list of elements in the arrangement and combination of the problem, the specific realization of the code you refer to the following article
    2018-03-03
  • python implement elegant print json format text

    This article introduces the python elegant print json format text way, with good reference value, I hope to help you, if there is an error or not consider the full place, look no advice!
    2024-08-08
  • PyQt5 daily must learn pixmap control QPixmap

    This article is mainly for you to introduce in detail the PyQt5 every day must learn the pixel map control QPixmap, with certain reference value, interested partners can refer to it
    2018-04-04
  • The most simplified ChatGLM2-6b white deployment tutorial [windows system, 16G RAM can be, no requirements for the graphics card, CPU running]

    This article introduces the most simplified ChatGLM2-6b white deployment method, can be in the windows system environment, 16G RAM and no requirements for the graphics card, and to run in CPU mode, to facilitate the realization of the deployment of personal PC environment experience, the need for friends can refer to the following
    2023-07-07
  • An In-Depth Look at Monitoring and Management of Python Ops Automation psutil Modules

    This article introduces the Python operations automation psutil module monitoring and management in-depth exploration, there is a need for friends can learn from reference, I hope to be able to help, I wish you more progress, early promotion and salary increase!
    2024-01-01

Latest Comments