Numeric look at Cadbury sweet products

Everyone loves sweet products, but children are especially exposed to them, frequently asking their parents for sweet candy. At a yong age they are not completely aware what these products contain. A parent might think about both satisfying their craving while at the same time minimizing the effects of food that could harm them.

Cadbury is a company that offers a variety of chocolate bars, blocks, biscuits, bags & boxes, easter products and sweet drinks. Looking at their website, we see many products a child could be asking for. The company has listed nutrition values per 100g for all of their products, which is admirable, because such information is often not provided. This allows us to compare whether there is a difference in the values of two chocolate bars, for instance.

columns = ['Product name', 'Energy (KJ)', 'Energy (Kcal)', 'Total fat (g)', 'Saturated fat (g)', 'Carbohydrates (g)', 'Sugar (g)', 'Fibre (g)', 'Protein (g)', 'Equivalent as salt (g)'] products = """ Cadbury Boost,2153,515,28,20,59,52,1.9,5.6,0.33 CADBURY Bournville,2190,524,28,17,60,58,6,4.1,0.01 CADBURY Chomp,1950,465,20,10,68,48,0.7,2.8,0.42 CADBURY Crunchie,1955,465,17,10,74,65,1.3,3.1,0.72 CADBURY Curly Wurly,1905,453,18,9.5,70,49,0.7,3.1,0.58 CADBURY Double Decker,1929,459,16,8.6,73,54,1.5,3.7,0.19 CADBURY Flake,2179,521,27,16,60,59,2.4,7.4,0.26 CADBURY Fry's Chocolate Cream,1744,414,13,7.9,71,66,3.3,2.3,0.01 CADBURY Fry's Peppermint Delight,1744,414,13,7.9,71,66,3.3,2.3,0.01 CADBURY Fry's Turkish Delight,1534,363,6.7,3.8,74,64,1.2,1.2,0.36 CADBURY Fudge,1884,448,15,8.2,74,65,0.6,2.4,0.34 CADBURY Picnic,2005,479,23,9.8,60,45,2.5,7.3,0.45 CADBURY Snack Sandwich,1925,460,25.5,15.5,52,38.5,0.7,5.8,0.43 CADBURY Snack Shortcake,1985,475,25.5,12.5,53.5,26,1.7,7,0.53 CADBURY Starbar,2126,509,28,14,53,44,2.7,10,0.35 CADBURY Timeout Wafer,2202,527,29,16,60,45,2.1,6.7,0.35 CADBURY Twirl,2209,528,29,17,59,58,2.3,7,0.26 CADBURY Wispa,2309,554,34,21,53,52,2.3,7.1,0.22 CADBURY Wispa Gold,2123,508,28,16,59,49,1.6,5.1,0.33 CADBURY DAIRY MILK Big Taste Peanut Caramel,2264,543,33,16,50,47,2.5,9.8,0.34 CADBURY DAIRY MILK Big Taste Toffee Wholenut,2331,560,37,18,50,48,1.9,6.4,0.32 CADBURY DAIRY MILK Cadbury Dairy Milk,2232,534,30,18,57,56,2.1,7.3,0.24 CADBURY DAIRY MILK Caramel,2027,484,23,14,63,53,1.2,4.7,0.37 CADBURY DAIRY MILK Freddo,2210,530,30.5,18.5,56.5,56,0.7,7.5,0.23 CADBURY DAIRY MILK Freddo Caramel,2076,496,26,15,59,52,1.6,5.7,0.32 CADBURY DAIRY MILK Fruit & Nut,2127,509,28,15,56,53,2.7,7.8,0.19 CADBURY DAIRY MILK Jelly Popping Candy,2136,511,26,16,61,58,1.8,6.3,0.21 CADBURY DAIRY MILK Mint Oreo bar,2308,553,34,19,55,48,1.7,6.1,0.44 CADBURY DAIRY MILK Oreo,2308,553,34,19,55,48,1.7,6.1,0.44 CADBURY DAIRY MILK Wholenut,2276,546,34,16,50,49,3,8.3,0.21 CADBURY DAIRY MILK Big Taste Oreo Crunch,2328,558,35,20,54,47,1.3,5.6,0.47 CADBURY DAIRY MILK Big Taste Peanut Caramel Crisp,2280,547,34,16,49,47,2.5,9.8,0.33 CADBURY DAIRY MILK Big Taste Toffee Wholenut,2320,557,36,18,51,50,1.8,6.3,0.32 CADBURY DAIRY MILK Big Taste Triple Choc,2258,541,31,19,57,56,2.1,6.1,0.30 CADBURY DAIRY MILK Chopped Nut,2280,547,33,17,52,51,2.5,7.9,0.22 CADBURY DAIRY MILK CRUNCHIE BITS,2128,508,25,15,64,58,1.7,6,0.30 CADBURY DAIRY MILK Daim,2200,525,30.5,17.5,57,56.5,0.7,6.4,0.43 CADBURY DAIRY MILK Medley Biscuit and Fudge,2310,555,34,19,54.5,51,2,5.9,0.28 CADBURY DAIRY MILK Medley Hazelnut and Raspberry,2345,560,36,19.5,52.5,51.5,2.4,6,0.23 CADBURY DAIRY MILK Oreo Mint Flavour,2325,557,35,20,54,49,1.5,5.9,0.42 CADBURY DAIRY MILK Oreo Peanut Butter Flavour,2329,558,35,20,54,48,1.5,5.9,0.42 CADBURY DAIRY MILK Tiffin,2102,502,25,15,60,54,2.1,6.7,0.26 CADBURY DAIRY MILK Wholenut,2300,550,35.5,16.5,49,48,1.7,8.8,0.2 MARVELLOUS SMASHABLES Jelly Popping Candy,2135,510,26.5,16,61,58.5,1.6,6.2,0.23 CADBURY Bitsa Wispa,2290,550,34,21,52.5,52.5,1,7.3,0.23 CADBURY Boost Bites,2158,516,29,20,59,52,1.8,5.6,0.3 CADBURY Caramel Nibbles,2080,497,26,15,59,52,1.6,5.7,0.32 CADBURY Crunchie Rocks,2008,478,19,11,71,55,2,4.7,0.61 CADBURY Curly Wurly Squirlies,1901,452,18,9.5,70,49,0.7,3.1,0.59 CADBURY Dinky Decker,1915,456,17,10,71,53,1.5,4.2,0.26 CADBURY Eclairs,1900,452,17,9.1,71,48,0,4.2,0.48 CADBURY Eclairs Velvets,1875,447,19,14,69,52,0,3.1,0.22 CADBURY Fudge Minis,1912,455,17,9.0,73,64,0.7,2.6,0.33 CADBURY Heroes,2025,438,22,13,65,57,1.3,4.6,0.29 CADBURY Milk Tray,2168,518,27,15,64,57,1.6,3.8,0.32 CADBURY Picnic Bites,2140,512,29,12,52,38,3.2,9.7,0.45 CADBURY Roses,2059,492,24,13,64,56,1.4,4.2,0.37 CADBURY Twirl Bites,2207,528,29,17,59,58,2.3,7,0.26 CADBURY DAIRY MILK Buttons,2234,535,30,18,57,56,2.1,7.3,0.24 CADBURY DAIRY MILK Freddo Faces,2216,529,30,18,57,56,2.1,7.3,0.24 CADBURY DAIRY MILK Giant Buttons,2234,535,30,18,57,56,2.1,7.3,0.24 CADBURY DAIRY MILK Mixed Buttons,2246,537,30,18,60,59,1.1,6.2,0.31 CADBURY DAIRY MILK White Buttons,2250,540,29.5,18.5,63,63,0,4.7,0.4 CADBURY Bournville Cocoa,1701,410,20,15,14,9.7,34,23,1.39 CADBURY Drinking Chocolate,1697,402,5.6,4.1,76,73,9.3,6.3,0.38 CADBURY Freddo Drinking Chocolate,1697,402,5.6,4.1,76,73,9.3,6.3,0.38 CADBURY Highlights Bournville,1483,354,12,9.5,34,23,15,17,2.72 CADBURY Highlights Fudge,1466,349,11,8.1,42,32,9.1,16,2.63 CADBURY Highlights Milk Chocolate,1457,347,11,9.6,37,28,11,17,3.11 CADBURY Hot Chocolate Instant,1742,413,9.3,7.1,71,61,5.8,8,1.6 CADBURY Wispa Drinking Chocolate,1681,397,5.3,3.7,74,60,3.5,11,1.2 """ import numpy as np import pandas as pd import seaborn as sns from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler import matplotlib.pyplot as plt sns.set_style('white') fig, ax = plt.subplots(figsize=(6.5, 6)) pca = PCA(n_components=2) ss = StandardScaler() product_names, product_features = [], [] for row in products.split('\n')[1:-1]: prod, energy_kj, energy_kcal, total_fat, saturated_fat, carbohydrates, sugar, fibre, protein, equivalent_as_salt = row.split(',') data = list(map(float, [energy_kj, energy_kcal, total_fat, saturated_fat, carbohydrates, sugar, fibre, protein, equivalent_as_salt])) product_features.append(data) product_names.append(prod) product_features = np.array(product_features, dtype=float) for idx in [1, 2, 4, 5, 6, 7, 8, 9]: product_feature_name_unit = columns[idx] product_feature, value_unit = product_feature_name_unit.split(' (') product_feature = product_feature.lower() value_unit = value_unit[:-1] feat = product_features[:, idx-1] product = product_names[np.argmax(feat)] value = np.max(feat) print('Product with most {0}: {1} ({2:.2f} {3})'.format(product_feature, product, value, value_unit)) transformed = ss.fit_transform(product_features) transformed = pca.fit_transform(transformed) ha = 'center' for idx, (x,y) in enumerate(transformed): plt.plot(x, y, '.', markersize=5) if x > 2 or y > 2: if x > 2: ha, xdiff = 'left', 1 if y > 2: ha, xdiff = 'right', -1 xdiff *= 0.05 plt.annotate(product_names[idx], xy=(x, y), xytext=(x+xdiff, y), ha=ha, va='center', fontsize=9) plt.tight_layout() plt.show()

After we run this code we obtain the following result:

Product with most energy: CADBURY DAIRY MILK Medley Hazelnut and Raspberry (2345.00 KJ) Product with most energy: CADBURY DAIRY MILK Big Taste Toffee Wholenut (560.00 Kcal) Product with most saturated fat: CADBURY Wispa (21.00 g) Product with most carbohydrates: CADBURY Drinking Chocolate (76.00 g) Product with most sugar: CADBURY Drinking Chocolate (73.00 g) Product with most fibre: CADBURY Bournville Cocoa (34.00 g) Product with most protein: CADBURY Bournville Cocoa (23.00 g) Product with most equivalent as salt: CADBURY Highlights Milk Chocolate (3.11 g)

According to VerywellFit, children who are 10 years old need ≈1800 calories/day. This means that by choosing the Big Taste Toffee Wholenut (560 calories), they would need only 321g to fulfill their daily calorie intake. Imagine the effect of the same product on a 5-year old child. It is not hard to see why consistently reaching for sweet snacks in large amounts can quickly lead to obesity. In older people, food rich in sugar has been linked with increased risk of diabetes as well.

In this list we see that chocolate and cocoa appear multiple times. The Drinking Chocolate is said to contain 73g sugar for each 100g of content. And the Wispa is said to contain 21g saturated fat per 100g. What is interesting is that despite having an equal amount of kcal energy, the Big Taste Toffee Wholenut is said to have 14 KJ less energy than the Medley Hazelnut and Raspberry. I am not sure what the reason for this might be.

Similarly, changing the max for a min values gives us:

Product with least energy: CADBURY Highlights Milk Chocolate (1457.00 KJ) Product with least energy: CADBURY Highlights Milk Chocolate (347.00 Kcal) Product with least saturated fat: CADBURY Wispa Drinking Chocolate (3.70 g) Product with least carbohydrates: CADBURY Bournville Cocoa (14.00 g) Product with least sugar: CADBURY Bournville Cocoa (9.70 g) Product with least fibre: CADBURY Eclairs (0.00 g) Product with least protein: CADBURY Fry's Turkish Delight (1.20 g) Product with least equivalent as salt: CADBURY Bournville (0.01 g)

CADBURY Bournville Cocoa has the least amount of carbohydrates and sugar, but once again, it is a drink.

What if your child is already grabbing sweet bars? We replace the -1 with 31 in the above code and rerun it.

Product with most energy: CADBURY DAIRY MILK Big Taste Toffee Wholenut (2331.00 KJ) Product with most energy: CADBURY DAIRY MILK Big Taste Toffee Wholenut (560.00 Kcal) Product with most saturated fat: CADBURY Wispa (21.00 g) Product with most carbohydrates: CADBURY Crunchie (74.00 g) Product with most sugar: CADBURY Fry's Chocolate Cream (66.00 g) Product with most fibre: CADBURY Bournville (6.00 g) Product with most protein: CADBURY Starbar (10.00 g) Product with most equivalent as salt: CADBURY Crunchie (0.72 g) Product with least energy: CADBURY Fry's Turkish Delight (1534.00 KJ) Product with least energy: CADBURY Fry's Turkish Delight (363.00 Kcal) Product with least saturated fat: CADBURY Fry's Turkish Delight (3.80 g) Product with least carbohydrates: CADBURY DAIRY MILK Big Taste Peanut Caramel (50.00 g) Product with least sugar: CADBURY Snack Shortcake (26.00 g) Product with least fibre: CADBURY Fudge (0.60 g) Product with least protein: CADBURY Fry's Turkish Delight (1.20 g) Product with least equivalent as salt: CADBURY Bournville (0.01 g)

The Fry's Turkish Delight seems like a good compromise in terms of calories and fat, but it also doesn't have a lot of protein. If your child chose the Fry's Chocolate Cream, it is probably better to return it to its place since it has 66g sugar (in 100g). The Snack Shortcake has 40g less.

We could use PCA to try highlighting potentially interesting information:

PCA on the features of most Cadbury products

Despite mixing many types of products, PCA was able to identify some with distinct properties. All overlapping labels here refer to some form of a drinking chocolate. After seeing the previous list, it is not surprising why they also appear here. Relative to the bars for instance, the drinks seem to contain slightly more carbohydrates and sometimes a lot more sugar.

We could temporarily comment out the plot and annotate functions and insert this code to create a correlation matrix:

df = pd.DataFrame(product_features, columns=columns[1:]) sns.heatmap(df.corr(), cmap=plt.cm.jet, vmin=-1, vmax=1, center=0, square=True, linewidths=.5, cbar_kws={"shrink": .82}, annot=True, fmt='.2g') plt.xticks(rotation=90, fontsize=12) plt.yticks(rotation=0, fontsize=12) Correlation of the product features of Cadbury products

We see a "perfect" correlation between energy given in KJ and kcal. But we also see that total fat contributes most to the energy in the products. That saturated fat is linked to total fat is not surprising, since it is a portion of it. Similarly, sugar content is a portion of the total carbohydrate content. But that protein-fiber and protein-salt are somewhat correlated here may be a characteristic of the way the products were produced. Least correlated seem to be carbohydrates and protein.

Final words

Using data to identify products with desirable characteristics and comparing alternatives helps us to ensure that the people we love most are also well protected from the marketing efforts of companies seeking to extract pure profit. A child doesn't know and is vulnerable; this can be used in all kinds of ways if the parent is unaware.

Yet, even sweet products have their place. Now and then even people who stay away from sugar for too long can't resist them. The only trouble is when their consumption becomes habitual.