Machine Learning Tutorial Python - 6: Dummy Variables & One Hot Encoding

Опубликовано: 30 September 2026
на канале: codebasics
507,462
7k

Machine learning models work very well for dataset having only numbers. But how do we handle text information in dataset? Simple approach is to use interger or label encoding but when categorical variables are nominal, using simple label encoding can be problematic. One hot encoding is the technique that can help in this situation. In this tutorial, we will use pandas get_dummies method to create dummy variables that allows us to perform one hot encoding on given dataset. Alternatively we can use sklearn.preprocessing OneHotEncoder as well to create dummy variables.

#MachineLearning #PythonMachineLearning #MachineLearningTutorial #Python #PythonTutorial #PythonTraining #MachineLearningCource #OneHotEncoding #sklearntutorials #scikitlearntutorials

Code in tutorial: https://github.com/codebasics/py/blob...

Exercise csv file: https://github.com/codebasics/py/blob...

Exercise solution: https://github.com/codebasics/py/blob...

Topics that are covered in this Video:
0:00 Introduction
0:47 How to handle text data in machine learning model?
1:38 Nominal vs Ordinal Variables
2:44 Theory (Explain one hot encoding using home prices in different townships)
3:39 Coding (Start)
3:51 Pandas get_dummies method
7:48 Create a model that uses dummy columns
12:45 Label Encoder
13:29 fit_transform() method
15:40 sklearn OneHotEncoder
19:59 Exercise (To predict prices of car based on car model, age, mileage)

Do you want to learn technology from me? Check https://resources.codebasics.io/Igmopd for my affordable video courses.

Next Video:
Machine Learning Tutorial Python - 7: Training and Testing Data:    • Machine Learning Tutorial Python - 7: Trai...  

Populor Playlist:
Data Science Full Course:    • Data Science Full Course For Beginners | P...  

Data Science Project:    • Machine Learning & Data Science Project - ...  

Machine learning tutorials:    • Machine Learning Tutorial Python -1: What ...  

Pandas:    • Python Pandas Tutorial 1. What is Pandas p...  

matplotlib:    • Matplotlib Tutorial 1 - Introduction and I...  

Python:    • Why Should You Learn Python? | Complete py...  

Jupyter Notebook:    • What is Jupyter Notebook? | Jupyter Notebo...  

To download csv and code for all tutorials: go to https://github.com/codebasics/py, click on a green button to clone or download the entire repository and then go to relevant folder to get access to that specific file.

Tools and Libraries:
Scikit learn tutorials
Sklearn tutorials
Machine learning with scikit learn tutorials
Machine learning with sklearn tutorials

🌎 My Website For Video Courses: https://resources.codebasics.io/Igmopd

Need help building software or data analytics and AI solutions? My company https://www.atliq.com/ can help. Click on the Contact button on that website.

#️⃣ Social Media #️⃣
🔗 Discord:   / discord  
📸 Codebasics Instagram:   / codebasicshub  
🔊 Codebasics Facebook:   / codebasicshub  
📝 Codebasics LinkedIn:   / codebasics  
📱 Codebasics X handle:   / codebasicshub  
📸 Dhaval's Instagram:   / dhavalsays  
📝 Dhaval's LinkedIn:   / dhavalsays  
📱 Dhaval's X handle: https://x.com/dpcodebasics
🔗 Patreon: https://www.patreon.com/codebasics?fa...