# Used during prepprocessing to fix the sugar content values # that are incorrectly represented as "reg" instead of "Regular" in the dataset def fix_sugar_content(X): X = X.copy() X["Product_Sugar_Content"] = X["Product_Sugar_Content"].replace("reg", "Regular") return X # Feature engineering function to create a new feature for the # product ID prefix contained in the first two characters of the Product_Id def add_product_id_prefix(X): X = X.copy() X["Product_Id_Prefix"] = X["Product_Id"].str[:2] return X