<jupyter_start><jupyter_text>DATA PREPROCESSING<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sb
#Our dataset
shirt_order = pd.DataFrame({'Name':['Alex', 'Ben', 'Cam', 'Dave', 'Eli', 'Frank', 'Grace', 'Henry', 'Iris', 'Jack'],
                            'Gender':['F', 'M', 'M', 'M', 'F',  'M', 'F', 'M', 'F', 'M'],
                            'Size':['Small', 'Large', 'Medium', 'Small', 'Medium', 'Large', 'Large', 'Large', 'Small', 'Small'],
                            'Color':['Blue', 'Yellow', 'Red', 'Red', 'Yellow', 'Red', 'Blue', 'Yellow', 'Yellow', 'Blue']
                          })
#Visualize dataset
shirt_order
#LABEL ENCODING
from sklearn.preprocessing import LabelEncoder
#Create an object for Label Encoder
LE=LabelEncoder()
#Create a new column that will show you the encoded require column
shirt_order['Gender Category']=LE.fit_transform(shirt_order.Gender)
#Check
shirt_order
shirt_order.Size.unique()

#ORDINAL ENCODING
mapping_dict={'Small':0,'Medium':1,'Large':2}
shirt_order['Size Category']=shirt_order.Size.map(mapping_dict)
#check
shirt_order

#ONE HOT ENCODING
#duplicate color column for keeping the orginal values
shirt_order['color_category']=shirt_order.Color
shirt_order_onehotencoding=pd.get_dummies(shirt_order,columns=["color_category"],prefix=["Color"])
#check
shirt_order_onehotencoding<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16206652512384997, 'fraction_numerical': 0.0021231422505307855, 'mean_word_length': 4.867219917012448, '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': '211781', 'license': 'MIT', 'n_tokens_mistral': 473, 'n_tokens_neox': 461, 'n_words': 115, 'path': 'Data Preprocessing/Untitled.ipynb', 'repo_name': 'nit-ap/Machine-Learning-in-Python', 'size': '1413'}