Plate Pal: 2023 Edmonton Accelerator Award winner

Plate Pal
PlatePal

Team members

Aesha Patel, Anh Vo, Sana Shams, Tanya, and Urim Iyasere

Project summary

"Spice Up, Save Up" revolutionizes student nutrition, offering affordable and wholesome meal choices to combat food insecurity in Canada.

Keywords

Food insecurity, Affordable Nutrition, Food Access, Q-learning, Machine learning, Classification, Geospatial, social good.

Inspiration / background

We, a group of Canadian students, are united by our shared experiences, which serve as the foundation of our initiative. We have a deep understanding of the numerous difficulties that students just like us experience on a daily basis because we are fellow students. The lack of constant access to enough food as a result of the rising expense of life is one of the urgent issues that resonated with us. This problem doesn't simply affect us; it also affects other Canadians and immigrants who face comparable challenges.

It is heartbreaking to see how many more people—including ourselves—experience food insecurity, mostly as a result of the rising price of food. In response to this pressing issue, we've coined our project's guiding principle: "Spice Up, Save Up." This slogan embodies our commitment to tackling food-related challenges creatively and cost-effectively. A recent report from a national food rescue organization has highlighted that food banks and similar programs serving vulnerable Canadians are projected to experience a surge of 60% more users per month in 2023 compared to the previous year.

We started the process of developing a solution, motivated by a strong sense of empathy and the desire to bring about a positive change. Our group brainstorming meetings led to the creation of this software, which attempts to offer an immediate yet significant solution to the problems we've discovered. Our main objective is to equip other pupils with a tool that will enable them to overcome these difficulties related to food.

With the app, our aspiration is to enable students to discover affordable, convenient, and nutritionally balanced food options. We are aware personally of the importance of eating healthily for both academic achievement and general wellbeing. In order to help users make wise food choices even on a limited budget, our software has been carefully created.

A chart showing the three pillars of Plate Pal, collecting local promotions, maximizing purchasing power and customized grocery runs

List of Technologies

Backend: SQLite, CSV

Python Libraries: Geocoder, pandas, numpy, geopy, requests

Front-end: Figma, Canva, Django

Detailed description

The primary objective of our project, Plate Pal, is to address the pressing issue of food insecurity by developing a user-friendly website. This platform is designed to alleviate the challenges faced by individuals with limited access to affordable groceries. Leveraging a user's postal code, Plate Pal generates a curated list of the most budget-friendly grocery options available within their local area, all while taking into careful consideration their specific dietary restrictions. Our project aims to create a seamless and empowering experience for users, enabling them to make informed decisions about their food choices. The overarching goals include compiling a comprehensive list of weekly offers from nearby grocery stores, optimizing the purchasing power of users, and providing a stress-free solution through a personalized grocery plan. By offering tailored recommendations based on location, dietary needs, and budget constraints, Plate Pal's goal is to not just improve the affordability of food and address food insecurity, but also promote healthier eating habits.

Project development

Plate Pal's journey began with a strong brainstorming session, aiming to blend AI technology with new ideas. We collected data using web scraping from places like Flipp, known for its grocery deals, which formed the base of our information. This helped us use an algorithm, called q-learning, in our machine learning approach. It helped us choose groceries better based on cost and dietary needs. This flexibility made Plate Pal give personal suggestions to users. During development, we kept things simple for users, making it easy to put in their location, get real-time store deals, choose their food restrictions, and set a budget for cheaper meals. Combining data collection, machine learning methods, and user-friendly design led to Plate Pal's creation as a new way to help with not having enough food, making life better for users. More details about how we did this can be found in the technical implementation section.

Technical implementation overview of the app: web scraping, geolocation, Q-learning, and reinforcement learning components

Implementation

The code implements a data retrieval system using APIs and SQLite for item classification based on location and price. Additionally, it employs Q-learning to optimize product selection within budget constraints, facilitating effective decision-making in shopping scenarios. It also comprises two distinct components aimed at classifying items and finding optimal products based on available data:

Item Classification and Data Retrieval

  1. Web Scraping and Data Management:
    • Utilized the `requests` library to fetch data from Flipp's API for item information.
    • Employed the `geocoder` library to retrieve latitude and longitude coordinates from postal codes.
    • Created a SQLite database (`items.db`) using `sqlite3` to store item-related data.
    • Designed a `Store` class to represent stores with names and postal codes.
    • Implemented a `FlyerScraper` class responsible for managing data retrieval and storage.
  2. Data Storage and Querying:
    • Established an SQLite database table named `items` to store item details like store name, item name, price, longitude, latitude, and postal code.
    • Incorporated methods within the `FlyerScraper` class to insert item data into the SQLite database and retrieve search results for items.
  3. Search and Store Scrape:
    • Defined methods for searching items using the `SEARCH_URL` and scraping individual item data using the `ITEM_URL`.
    • Integrated the `geopy` library to calculate distances between locations using latitude and longitude coordinates.

Q-Learning for Product Optimization

  1. Q-Learning Agent Initialization:
    • Developed a `QLearningAgent` class to perform Q-learning for product optimization.
    • Initialized the agent with essential parameters, including the list of categories, budget, learning rate, discount factor, and exploration probability (`epsilon`).
  2. Q-Value Update and Action Selection:
    • Implemented methods to update Q-values based on reward and future Q-values.
    • Designed a method for selecting actions using a trade-off between exploration and exploitation.
  3. Optimal Product Search and Selection:
    • Developed functions to identify optimal products considering the available budget and the number of episodes.
    • Employed random and optimal action selection to determine the best products within budget constraints.
  4. CSV Data Processing:
    • Utilized the `csv` library to read data from a CSV file (`output.csv`) containing item information.
    • Prepared data for optimal product search by creating a list of items, including store, item, price, and category.
  5. Execution and Output:
    • Created an instance of the `QLearningAgent` with specified parameters.
    • Executed Q-learning optimization for a set number of episodes.
    • Printed the list of optimal products based on the learned Q-values and budget considerations.

Impact and Innovation

At the moment, there are a handful of flyer-based grocery websites and apps that have weekly sales at various grocery stores. These services provide users with weekly ads and coupons for grocery stores where users can browse and clip digital coupons. When grocery shopping the key points of consideration are: food group, budget, and location. These features are taken into consideration in the pre-existing services, but there are a few shortcomings. Some categorize their flyers into groups such as Groceries, Pharmacy, Office, etc. but currently, flyers are not categorized into food groups such as dairy, grains, meats and proteins, fruits and vegetables. Furthermore, currently available services do not have a feature for the user to enter their grocery budget and it is up to the reader to collect and budget their grocery run themselves. This is where PlatePal stands out.

PlatePal takes one step further in improving the user’s grocery experience by taking on nutritional and budgetary considerations. The vision that this project was built upon was accessible and affordable groceries. Unfortunately, because of the cost disparity between healthy vs. unhealthy foods, those facing food insecurity may struggle with purchasing a balanced diet.1 To tackle this, PlatePal allows users to enter their budget; Q-Learning is employed for product optimization as described in Technical Implementation to find the optimal combination of the main food groups within the user’s budget. Through this, PlatePal respects the user’s budgetary constraints while still generating a balanced, customized grocery run. In addition to this, the geolocation filter feature further customizes the grocery run to stores that are within a certain range of the user.

A chart showing that Plate Pal beats similar apps, Checkout51, Flipp and rb, in terms of accessibility, affordability and nutritional value of groceries

All these features combined set PlatePal apart by providing a more holistic user experience that ultimately improves the user’s access to affordable groceries without sacrificing nutritional balance and budgetary constraints.

Challenges we ran into & how we overcame them

A main challenge we faced was making sure our web scraping functionality worked smoothly with our database. This meant we needed to understand how to get data and store it correctly, and also adapt our Python script to handle the regularly updated data from Flipp without any hiccups. To tackle this challenge, we did thorough research, reached out to online communities for advice, and kept refining our code until it reliably collected the latest grocery information and stored it in our database. It's worth noting that we organized all the data we scraped in SQL3 data types and later converted it into a Pandas dataframe for easier processing and analysis. This careful data management approach turned out to be a key factor in the success of our project.

What we learned & accomplishments we’re proud of

The AI4Good Lab was an invaluable learning experience for our team. Going into the program, we all came from diverse backgrounds and skill sets, but a similar passion for doing something good in AI. With the help of lectures, workshops, and TA & mentoring sessions, our team was able to not only learn the fundamentals of machine learning and AI but also adopt a creative approach to making our shared vision a reality. This collaborative setting was mind-stimulating and incredibly rewarding because it encouraged active learning as we shared perspectives and brainstormed a project idea collectively. Throughout the boot camp, networking events were also organized which our team greatly utilized. Connecting with some of the guest speakers and academic professionals, we gained further insight into problem-solving innovative solutions and using a real-world approach to develop an inclusive prototype that empathizes with social change for all. Such experiences were immensely valuable to our team during the project planning and development stages, as we explored additional resources outside of the scope of the program to broaden our computing knowledge, specifically in ML algorithms, and leverage our prototype. Thanks to all the insightful feedback and technical support provided by AI4GoodLab, our team was able to successfully pitch our app, ‘Plate Pal’ on Demo Day and receive the 2023 Accelerator Award as part of the Edmonton cohort. We are truly grateful for this wonderful accomplishment which marks a significant milestone in our 7-week journey, and the given opportunity to showcase our final project that can make a difference in society today!

What’s next

A timeline showing next phases of app development for Plate Pal 2.0
  1. Strengthening Relationships with Local Grocers: We aim to enhance our connections with local grocers by actively diversifying our network. This approach allows us to expand our access to a broader range of fresh and diverse food options, catering to the specific dietary needs and preferences of our users.
  2. Categorization: By leveraging the capabilities of NLP systems, we can effectively categorize food items and utilize this information to suggest well-balanced meals that align with the categorized grocery items. This approach enables personalized and tailored recommendations for a healthy and balanced diet.
  3. Enhanced Meal & Nutritional Planning: By expanding the scope of our NLP systems, we can accommodate a wider range of dietary restrictions, such as halal guidelines, specific allergies like peanuts, and conditions like celiac disease. This allows us to provide even more personalized meal recommendations that cater to individual needs and ensure adherence to specific dietary requirements.
  4. Budget-Conscious Grocery List Generation: Our ongoing efforts include modifying the reinforcement learning (RL) algorithm to generate grocery lists that align with a specified budget. This optimization ensures that users can plan their meals effectively while considering financial constraints, making their shopping experience more efficient and cost-effective.

Acknowledgements

PlatePal would not have been possible if it was not for the unwavering support from our dedicated TA, Samridhi Vaid, and our mentor, Joud El-Shawa. Despite our many challenges, Samridhi was always right behind us and guided us so that we never felt an obstacle was too large — and indeed with her support and knowledge in machine learning, they never were. Moreover, Joud’s background in data science was immensely helpful given that PlatePal relies on processing our scraped data, making our database a key challenge. Both Samridhi and Joud went far beyond technical mentorship though, from research to pitching, they championed us in any and all of our endeavors. And of course, beyond the content and resources, it was all the amazing people at the AI4Good Lab program that made this experience. From our fellow trainees to the curriculum providers, to the administrative team, we are so grateful for everyone’s genuine passion for supporting and empowering us at every stage!

References

Kern, David M et al. “Neighborhood Prices of Healthier and Unhealthier Foods and Associations with Diet Quality: Evidence from the Multi-Ethnic Study of Atherosclerosis.” International journal of environmental research and public health vol. 14,11 1394. 16 Nov. 2017, doi:10.3390/ijerph14111394

Pasieka, C. (2023, January 12). 60% more Canadians per month expected to use food banks, other programs in 2023, survey finds | CBC News. CBCnews.

1 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5708033/

Categorized under