<jupyter_start><jupyter_text>Tutorial for using the package `fast-ml` This package is as good as having a junior Data Scientist working for you. Most of the commonly used EDA steps, Missing Data Imputation techniques, Feature Engineering steps are covered in a ready to use format  Part 5. Feature Engineering for Categorical Variables / Categorical Encodings 1. Import eda module from the package `from fast_ml.feature_engineering import FeatureEngineering_Categorical` 2. Define the imputer object. * For Categorical variables use `FeatureEngineering_Categorical`* For Numerical variables use `FeatureEngineering_Numerical``cat_imputer = FeatureEngineering_Categorical(method = 'label')` 3. Fit the object on your dataframe and provide a list of variables`cat_imputer.fit(train, variables = ['BsmtQual'])` 4. Apply the transform method on train / test dataset`train = cat_imputer.transform(train)`&`test = cat_imputer.transform(test)` 5. parameter dictionary gets created which store the values used for encoding. It can be viewed as`cat_imputer.param_dict_`  Available Methods for Categorical Encoding1. One-hot Encoding1. Label Encoding / Integer Encoding1. Count Encoding1. Frequeny Encoding1. Ordered Label EncodingTarget Based Encoding6. Target Ordered Encoding7. Target Mean Value Encoding8. Target Probability Ratio Encoding (only Classification model)9. Weight of Evidence (WOE) Encoding (only Classification model)  Start Feature Engineering for Categorical Variables<jupyter_code># Import Libraries

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

from fast_ml.feature_engineering import FeatureEngineering_Categorical

%matplotlib inline

import warnings
warnings.filterwarnings('ignore')
df = pd.read_csv('../data/house_prices.csv')
df.shape
df.head(5)
numeric_type = ['float64', 'int64']
category_type = ['object']<jupyter_output><empty_output><jupyter_text>Categorical Variables  1. BsmtQual<jupyter_code>#Before Imputation
df['BsmtQual'].value_counts()
cat_imputer1 = FeatureEngineering_Categorical(method = 'label')
cat_imputer1.fit(df, variables = ['BsmtQual'])
cat_imputer1.param_dict_
df = cat_imputer1.transform(df)
#After Imputation
df['BsmtQual'].value_counts()<jupyter_output><empty_output><jupyter_text>2. FireplaceQu<jupyter_code>#Before Imputation
df['FireplaceQu'].value_counts()
cat_imputer2 = FeatureEngineering_Categorical(method = 'freq')
cat_imputer2.fit(df, variables = ['FireplaceQu'])

print (cat_imputer2.param_dict_)

df = cat_imputer2.transform(df)
#After Imputation
df['FireplaceQu'].value_counts()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08260038240917782, 'fraction_numerical': 0.011472275334608031, 'mean_word_length': 7.175, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '497779', 'license': 'MIT', 'n_tokens_mistral': 827, 'n_tokens_neox': 798, 'n_words': 239, 'path': 'tutorials/5 Tutorial for fast_ml - Feature Engineering for Categorical Variables.ipynb', 'repo_name': 'PrashantChowdharyTcs/fast_ml', 'size': '2615'}