How to do frequency encoding | Feature Engineering python
Feature Engineering python- In this video we will be feature encoding techniques and How to do frequency encoding also known as count or frequency encoding. we will discuss it with examples using python. Even if you use any other language such as Rstudio or scala , this video will be extremely helpful.
I this technique we simply replace our categories by the count or occurrence of that particular category.
I would encourage you to checkout my complete feature engineering playlist which will help you to learn and understand other feature engineering techniques also.
Feature Engineering playlist : https://youtube.com/playlist?list=PLyB8AGpv661FvHtb9jbNYSsnSANV4bkFG
pandas playlist : https://youtube.com/playlist?list=PLyB8AGpv661FAEgt1cNQKq_KeVpfFK21T
Source code for this video:
----------------------------------------------------------------------------
#!/usr/bin/env python
# coding: utf-8
import pandas as pd
from sklearn.model_selection import train_test_split
data = pd.read_csv('houseprice.csv', usecols=['MSZoning','Street','LotShape','Utilities','LandSlope','SalePrice'])
data.head()
data.isnull().mean()
X_train,X_test,y_train,y_test = train_test_split(data[['MSZoning','Street','LotShape','Utilities','LandSlope']],
data['SalePrice'], test_size =.3, random_state =111)
X_train.head()
X_train.shape
X_test.shape
y_train.shape
# In[32]:
y_train.head()
# In[33]:
Ms = X_train['MSZoning'].value_counts().to_dict()
Ms
cat_vars = ['MSZoning','Street','LotShape','Utilities','LandSlope']
encoder_dictionary ={}
for var in cat_vars:
encoder_dictionary[var] = (X_train[var].value_counts()/len(X_train)).to_dict()
encoder_dictionary
for var in cat_vars:
X_train[var] = X_train[var].map(encoder_dictionary[var])
X_train.head()
---------- End Source Code--------------------------------------------------
Related Tags:
How to deal with categorical data
Categorical encoding python
Machine learning tutorial
How to encode categorical variables
Count Encoding
One hot encoding
Feature engineering
Data Analytics
Видео How to do frequency encoding | Feature Engineering python канала Coder's Digest
I this technique we simply replace our categories by the count or occurrence of that particular category.
I would encourage you to checkout my complete feature engineering playlist which will help you to learn and understand other feature engineering techniques also.
Feature Engineering playlist : https://youtube.com/playlist?list=PLyB8AGpv661FvHtb9jbNYSsnSANV4bkFG
pandas playlist : https://youtube.com/playlist?list=PLyB8AGpv661FAEgt1cNQKq_KeVpfFK21T
Source code for this video:
----------------------------------------------------------------------------
#!/usr/bin/env python
# coding: utf-8
import pandas as pd
from sklearn.model_selection import train_test_split
data = pd.read_csv('houseprice.csv', usecols=['MSZoning','Street','LotShape','Utilities','LandSlope','SalePrice'])
data.head()
data.isnull().mean()
X_train,X_test,y_train,y_test = train_test_split(data[['MSZoning','Street','LotShape','Utilities','LandSlope']],
data['SalePrice'], test_size =.3, random_state =111)
X_train.head()
X_train.shape
X_test.shape
y_train.shape
# In[32]:
y_train.head()
# In[33]:
Ms = X_train['MSZoning'].value_counts().to_dict()
Ms
cat_vars = ['MSZoning','Street','LotShape','Utilities','LandSlope']
encoder_dictionary ={}
for var in cat_vars:
encoder_dictionary[var] = (X_train[var].value_counts()/len(X_train)).to_dict()
encoder_dictionary
for var in cat_vars:
X_train[var] = X_train[var].map(encoder_dictionary[var])
X_train.head()
---------- End Source Code--------------------------------------------------
Related Tags:
How to deal with categorical data
Categorical encoding python
Machine learning tutorial
How to encode categorical variables
Count Encoding
One hot encoding
Feature engineering
Data Analytics
Видео How to do frequency encoding | Feature Engineering python канала Coder's Digest
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Install Python 3.9 and PyCharm on Windows 10 | 2021 | PyCharm ide setup](https://i.ytimg.com/vi/nrxScUFjIFY/default.jpg)
![datetime python | date and time in python tutorial](https://i.ytimg.com/vi/hMjn-V8kgeA/default.jpg)
![How To Lock Individual Cells and Protect Sheets In Excel latest version | 2021](https://i.ytimg.com/vi/hBZlVhVZIh8/default.jpg)
![cart model in r | Regression Trees in R | decision trees](https://i.ytimg.com/vi/GsWaVGKjjpo/default.jpg)
![how to install julia language on windows | julia programming language](https://i.ytimg.com/vi/SUiPtercPyw/default.jpg)
![Dplyr in r | part 3 [ Group by, mutate, distinct , if else ]](https://i.ytimg.com/vi/T5ihUD79a7I/default.jpg)
![Gini Index and Entropy|Gini Index and Information gain in Decision Tree|Decision tree splitting rule](https://i.ytimg.com/vi/pKxriqSsShM/default.jpg)
![Dplyr in r | part 6 [ Sampling and rename functions ]](https://i.ytimg.com/vi/lNFE7BeMmgc/default.jpg)
![pandas index | pandas in python for beginners](https://i.ytimg.com/vi/u1JQpAr88uY/default.jpg)
![Dplyr in r | part 1 [ arrange function in r, scramble data, all_equal, Case ]](https://i.ytimg.com/vi/tX4R_R-17T4/default.jpg)
![google colab tutorial for beginners | Google Colab for machine learning and Deep learning | 2021](https://i.ytimg.com/vi/qCCdMq_wA8o/default.jpg)
![Dplyr in r | part 5 [ Joins in dplyr ] | innerjoin r](https://i.ytimg.com/vi/_oa8jJ7m65M/default.jpg)
![How to Set Up Your Data Science Environment (Anaconda Beginner) | (Conda Create)](https://i.ytimg.com/vi/w3kXtaZEtRs/default.jpg)
![Azure Virtual Machine Tutorial | how to create vm in azure | Azure tutorial for beginners](https://i.ytimg.com/vi/UGUGV72_eVQ/default.jpg)
![pandas python tutorial | Why and How to Use Pandas in Python](https://i.ytimg.com/vi/SCokVB-V5PA/default.jpg)
![r with sql | connect r to sql server | how to connect r to sql server](https://i.ytimg.com/vi/dkSOuVBGv2c/default.jpg)
![How to merge DataFrames in pandas | Pandas Tutorial for beginners](https://i.ytimg.com/vi/dbKvh5fMwNw/default.jpg)
![Feature Scaling Explained in Detail | how to do feature scaling in python | Machine Learning](https://i.ytimg.com/vi/wFuBUbfixzU/default.jpg)
![How to create virtual environment in python | python venv](https://i.ytimg.com/vi/aZ0na_-AQTQ/default.jpg)
![visual studio code for python | python in visual studio code tutorial | vscode python](https://i.ytimg.com/vi/Smg8YvLz42w/default.jpg)