<jupyter_start><jupyter_text>Count/Feature Encoding<jupyter_code>import pandas as pd
import numpy as np
dataset = pd.read_csv('data/train.csv',usecols=['X1','X2'])
dataset.head()
dataset.shape
dataset.nunique()
pd.get_dummies(dataset).shape
df_fequency_map = dataset.X2.value_counts().to_dict()
dataset.X2 = dataset.X2.map(df_fequency_map)
dataset.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14583333333333334, 'fraction_numerical': 0.013020833333333334, 'mean_word_length': 8.871794871794872, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '609944', 'license': 'Unlicense', 'n_tokens_mistral': 152, 'n_tokens_neox': 151, 'n_words': 20, 'path': 'Mercedes Benz Grenner Manufacturing (Feature Engineering)/.ipynb_checkpoints/Feature Encoding Implementation-checkpoint.ipynb', 'repo_name': 'yashrajjain726/Machine-Learning-Hands-On-Practice', 'size': '384'}