Giter Club home page Giter Club logo

minimum_sugar's People

Contributors

jrsmith3 avatar

Watchers

 avatar

Forkers

deanmalmgren

minimum_sugar's Issues

Flatten structure of data

The menu item data is presently held in a data structure that has unnecessary nesting. The menu item data should be contained in a list of dicts; each dict representing an individual menu item. Presently, the organization according to restaurant needlessly duplicates data and adds complexity.

This new, flatter structure requires that I write new tools to filter the data.

Check categorization of menu items using reported values

Some of the text reports generated in report.ipynb have results that indicate a problem in categorization. For example, in the "Maximum sugar" subsection the code

wendys_menu_items = minimum_sugar.filter_menu_items(menu_data, "brand_name", "Wendy's")
wendys_entree_items = minimum_sugar.filter_menu_items(wendys_menu_items, "menu_category", "entree")
wendys_high_sugar_menu_items = [menu_item for menu_item in wendys_entree_items if menu_item["nf_sugars"] > 18]
for menu_item in wendys_high_sugar_menu_items:
    print menu_item["item_name"] + ":", menu_item["nf_sugars"]    

returns a result "Double Chocolate Chip Cookie: 28". Clearly that menu item is mis-categorized.

Separate non-entree menu items

I only care about the sugar content of the entree menu items for any particular restaurant. Thus I should separate the following categories:

  • beverage
  • condiment
  • side order
  • dessert

Tag and release

I am nearing the point where I can release this report on my blog a la #11. I will tag the commit that gets posted to the blog using the YYYYMMDD rubric (I don't think semver applies here). Additionally, I need to tag a commit for which the notebook cells containing plotting directives have been executed and the plots generated.

Plot histogram of sugar data

I can plot histogram data of the various sugar content of the menu items. These would probably be a nice visualization.

Download data I need

I want a local copy of this data so I don't have to keep hitting Nutritionix's server.

Generate dict mapping restaurant names to UIDs

Nutritionix identifies restaurants by a unique ID number. For example, according to the API documentation, McDonald's ID is 513fbc1283aa2dc80c000053. I frequent the following places and need to determine the Nutritionix ID number for each:

  • McDonalds
  • Wendy's
  • Taco Bell
  • Qdoba
  • Chipotle
  • Five Guys
  • Costco

Add functionality to normalize histograms

I need functionality to make the histogram plots look uniform. Currently, the x scale for each restaurant is different because each restaurant has a different distribution of menu items. Additionally, the widths of the boxes in the histogram are different.

I am ultimately going to plot these histograms in a column and so the horizontal and vertical scales should match.

Organize code in fewer files

Presently (commit 1a7c11c), there are several files containing python source. The code in these files should be combined into a single library.

The following files should be concatenated:

  • data_manipulation.py
  • fetch_data.py
  • fetch_restaurant_ids.py

The file restaurant_menus.ipynb should be updated to reflect the change in the library.

Refactor to use SQLite instead of the list of dicts

I created a file named menu_data.json based on Nutritionix API calls, but I never committed that file to this repo. Nutritionix was nice enough to let me use their data, and I'm pretty sure they don't want me publishing it in my repo.

The menu_data.json file contains a list of dicts. A lot of the analysis would be easier if the menu data were contained in a SQLite database file. Thus, I need to:

  • Move data from menu_data.json to menu_data.db.
  • Refactor code to access menu_data.db instead.

`fetch_menu_item_data` returns duplicates

The following code will yield duplicate menu items.

# Assume `credentials` is a dictionary holding Nutritionix API credentials.
import minimum_sugar
import collections

# ID value 513fbc1283aa2dc80c000053 corresponds to McDonald's
menu_items = minimum_sugar.fetch_menu_item_data("513fbc1283aa2dc80c000053", credentials)
item_ids = [menu_item["item_id"] for menu_item in menu_items]

dups = [item for item, count in collections.Counter(item_ids).items() if count > 1]

print len(item_ids)
print len(item_ids) - len(dups)
print len(dups)

# Returns
#359
#347
#12

Write up report

Once #9 is closed, I need to write up a report of the results along with some development notes.

Refactor code to leverage `entree_items` list

Early in the report.ipynb, the following line of code occurs:

entree_items = minimum_sugar.filter_menu_items(menu_data, "menu_category", "entree")

Many times following that line, I re-sort the entree items from menu_data. I should refactor that code to rely on entree_items instead so I don't look like an amateur.

Write function to determine max value for particular restaurant menu item

I've repeated code that looks like the following as of 3143fbf

restaurant_name = "Taco Bell"

restaurant_menu_items = minimum_sugar.filter_menu_items(menu_data, "brand_name", restaurant_name)
restaurant_entree_items = minimum_sugar.filter_menu_items(restaurant_menu_items, "menu_category", "entree")
max_sugar = max(minimum_sugar.extract_variable(restaurant_entree_items, "nf_sugars"))

print "Max sugar:", max_sugar
menu_items = minimum_sugar.filter_menu_items(restaurant_entree_items, "nf_sugars", max_sugar)
for menu_item in menu_items:
    print "Item name:", menu_item["item_name"]

in order to determine the entree menu item(s) containing the most sugar for a particular restaurant. This code should be factored into its own function instead of copying and pasting it all over the place.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.