Skip to contents

The chocolates data was compiled by students at Iowa State University of STAT503 (circa 2015) taught by Dianne Cook. Nutrition label information on the chocolates as listed on manufacturer websites. All numbers were normalized to be equivalent to a 100g serving. Units of measurement are listed in the variable name.

Usage

chocolates

Format

A complete data.frame with 88 observations and 10 numeric variables, name of the chocolate, manufacturer, country, and type of the chocolate.

  • Name, the name of the chocolate

  • MFR, chocolate manufacturer

  • Country, the country the manufacturer is incorporated.

  • Type, the type of chocolate according to the website, either 'Dark' or 'Milk"

  • Calories, the number of calories per 100 grams

  • CalFat, calories from fat per 100 grams

  • TotFat_g, grams of total fat per 100 grams

  • SatFat_g, grams of saturated fat per 100 grams

  • Chol_mg, milligrams of cholesterol per 100 grams

  • Na_mg, milligrams of sodium (salt) per 100 grams

  • Carbs_g, grams of carbohydrates per 100 grams

  • Fiber_g, grams of fiber per 100 grams

  • Sugars_g, grams of sugar per 100 grams

  • Protein_g, grams of sugar per 100 grams

Source

Monash University, Introduction to Machine Learning course https://iml.numbat.space/

Replicating this dataset:

if(FALSE) ## Don't accidentally open the URL.
  browseURL("https://iml.numbat.space/")
## Accessed Jan 2022
chocolates <- readr::read_csv("https://iml.numbat.space/data/chocolates.csv")
chocolates <- data.frame(chocolates)
chocolates[, 2] <- factor(chocolates[, 2])
chocolates[, 3] <- factor(chocolates[, 3])
chocolates[, 4] <- factor(chocolates[, 4])
if(F){ ## Don't accidentally save
  save(chocolates, file = "./data/chocolates.rda")

Examples

library(cheem)

## Classification setup
X    <- chocolates[, 5:14]
Y    <- chocolates$Type
clas <- chocolates$Type

## Cheem
choc_chm <- cheem_ls(X, Y, chocolates_svm_shap, chocolates_svm_pred, clas,
                     label = "Chocolates, LM, shap")

## Save for use with shiny app (expects an rds file)
if(FALSE){ ## Don't accidentally save.
  saveRDS(choc_chm, "./chm_chocolates_svm_shap.rds")
  run_app() ## Select the saved rds file from the data dropdown.
}

## Cheem visuals
if(interactive()){
  prim <- 1
  comp <- 2
  global_view(peng_chm, primary_obs = prim, comparison_obs = comp)
  bas <- sug_basis(penguin_xgb_shap, prim, comp)
  mv  <- sug_manip_var(penguin_xgb_shap, primary_obs = prim, comp)
  ggt <- radial_cheem_tour(peng_chm, basis = bas, manip_var = mv)
  animate_plotly(ggt)
}