Python for Machine Learning | Label Encoding | Preprocessing - P16
Table of content
0:00 Introductions
00:08 What is Label Encoding
00:22 Why do we use Label Encoding
02:01 How to fill the categorical column with the modal values
02:21 How to use Dataframe.isnull().sum()
02:43 Extract features and labels
03:09 Import Imputer and OneHotEncoder
03:26 Create Dataframe with only features
03:34 Check Dataframe attribute with Dataframe.info()
03:54 Check the null values in the Dataframe df1 using df1.isnull().sum()
04:09 Label Encoding
04:14 Identify the columns on which we will apply Label Encoding
04:46 Define the object of Label Encoder
05:20 Apply Label Encoding on the respective categorical columns
05:41 Apply fit_transform on LabelEncoder()
06:14 How to create dataframe with the transformed features
Topic to be covered - Label Encoding
import pandas as pd
import numpy as np
df = pd.read_csv('Datapreprocessing.csv')
'''Get the rows that contains NULL (NaN)'''
df.isnull().sum()
'''Fill the NaN values for Occupation, Emplyment Status and Employement Type'''
col = ['Occupation','Employment Status','Employement Type']
df[col] = df[col].fillna(df.mode().iloc[0])
features = df.iloc[:,:-1].values
labels = df.iloc[:,-1].values
from sklearn.preprocessing import Imputer, OneHotEncoder
imputer = Imputer(missing_values='NaN',strategy='mean',axis=0)
'''2 step transformation
Fit and Tranform'''
imputer.fit(features[:,[1,6]])
features[:,[1,6]] = imputer.fit_transform(features[:,[1,6]])
'''------------------------------- L A B E L E N C O D I I N ------------------'''
from sklearn.preprocessing import LabelEncoder
encode = LabelEncoder()
features[:,0] = encode.fit_transform(features[:,0])
features[:,2] = encode.fit_transform(features[:,2])
features[:,3] = encode.fit_transform(features[:,3])
features[:,4] = encode.fit_transform(features[:,4])
features[:,5] = encode.fit_transform(features[:,5])
All Playlist of this youtube channel
====================================
1. Data Preprocessing in Machine Learning
• Data Preprocessing in Machine Learning| Li...
2. Confusion Matrix in Machine Learning, ML, AI
• Confusion Matrix in Machine Learning, ML, AI
3. Anaconda, Python Installation, Spyder, Jupyter Notebook, PyCharm, Graphviz
• Anaconda | Python Installation | Spyder | ...
4. Cross Validation, Sampling, train test split in Machine Learning
• Cross Validation | Sampling | train test s...
5. Drop and Delete Operations in Python Pandas
• Drop and Delete Operations in Python Pandas
6. Matrices and Vectors with python
• Matrices and Vectors with python
7. Detect Outliers in Machine Learning
• Detect Outliers in Machine Learning
8. TimeSeries preprocessing in Machine Learning
• TimeSeries preprocessing in Machine Learning
9. Handling Missing Values in Machine Learning
• Handling Missing Values in Machine Learning
10. Dummy Encoding Encoding in Machine Learning
• Label Encoding, One hot Encoding, Dummy En...
11. Data Visualisation with Python, Seaborn, Matplotlib
• Data Visualisation with Python, Matplotlib...
12. Feature Scaling in Machine Learning
• Feature Scaling in Machine Learning
13. Python 3 basics for Beginner
• Python | Python 3 Basics | Python for Begi...
14. Statistics with Python
• Statistics with Python
15. Sklearn Scikit Learn Machine Learning
• Sklearn Scikit Learn Machine Learning
16. Python Pandas Dataframe Operations
• Python Pandas Dataframe Operations
17. Linear Regression, Supervised Machine Learning
• Linear Regression | Supervised Machine Lea...
18 Interiew Questions on Machine Learning and Data Science
• Interview Question for Machine Learning, D...
19. Jupyter Notebook Operations
• Jupyter and Spyder Notebook Operations in ...
Информация по комментариям в разработке