Skip to main content

A BMI calculator and more!

Project description

bmigraph codecov Documentation Status example workflow

Authors: Qurat-ul-Ain Azim, Natalie Cho, HanChen Wang, Kelvin Wong

Project complete in accordance with DSCI 524 for the UBC MDS Program 2022-23 for Group 12

This python package is for calculation of BMI (body mass index), and some more computations based on weight loss goals. The package provides simple answers to a user's weight loss goals in terms of how much weight loss/gain and calorie deficit/increase should be aimed for with a target weight and time frame in mind. The package also provides helpful visualizations about BMI and calorie intake change trajectory leading to the target.

Functions

The package contains the following functions

  • calculate_bmi: computes user's BMI based on weight and height. Also creates a visual of the BMI on scale
  • project_bmi: computes how much average change in BMI should be achieved per day given a targeted weight and the timeframe to reach the goal. Also presents a visual trajectory for BMI
  • project_calories: computes how much average calorie intake is ideal per day given a targeted weight and the timeframe to reach the goal. Also presents a visual trajectory for calories
  • exercise_plan: suggests possible exercise plans to achieve the targeted weight. Also gives a graph showing how much exercise of each kind is needed per day

Suitability within Python Ecosystem

Our BMI calculator is unique in the sense that it provides easy and instantly understandable visuals to quickly get the gist of how healthy a person is. The package does not rely on any historical data of a person's weights, and hence needs no dataset files to be provided. The only arguments needed for the functions of this calculator are current weight and height, and target weight with timeframe in case weight change is desired. It also recommends simple figures for weight gain/loss goals. There are many BMI calculators in the Python ecosystem. Some of the examples can be found here and here. Both these offer limited visual aid in understanding one's health metrics and targets related to BMI.

Installation

$ pip install bmigraph

Usage

To use the package, import the package with following command:

from bmigraph import calculate_bmi, exercise_plan, project_bmi, project_calories

To use the functions, see examples below:

Calculate BMI

# Weight 100kg, height 1.85 meters, BMI value returned.
calculate_bmi(100, 1.85, return_graph=False)
# 29.218407596785973

# Weight 100kg, height 1.85 meters, BMI graph returned.
calculate_bmi(100, 1.85, return_graph=True)

BMI graph

Compute average BMI change per week

# Weight 100kg, height 1.85 meters, BMI goal 25, 30 days to reach goal, return average BMI change per week. 
project_bmi(100, 1.85, 25, 30, return_graph=False)
# -0.98

# Weight 100kg, height 1.85 meters, BMI goal 25, 30 days to reach goal, return plot of Projected BMI trajectory. 
project_bmi(100, 1.85, 25, 30, return_graph=True)

Projected BMI trajectory graph

Compute caloric intake per day based in a target weight

# Weight 100kg, height 1.85 meters, male, 25 years old, moderate exercise 3-5 times a week, ideal weight 75kg, 
# 25 days to reach goal, return caloric intake per day based in a target weight. 
project_calories(100, 1.85, 1, 25, 1.6, 75, 25, return_graph=False)
# 2417.0400000000004

# Weight 100kg, height 1.85 meters, male, 25 years old, moderate exercise 3-5 times a week, ideal weight 75kg, 
# 25 days to reach goal, return plot of Projected Weight Loss. 
project_calories(100, 1.85, 1, 25, 1.6, 75, 25, return_graph=True)

Projected Weight Loss graph

Create an exercise plan

# Weight 100kg, height 1.83 meters, female, aged 27
# Target weight: 68kg in 30 days
exercise_plan(100, 1.83, 2, 27, 68, 30)
# {'Leisure cycling or walking': 213,
# 'Moderate rope-jumping': 88,
# 'General running': 112,
# 'Leisure swimming': 156}

# Weight 100kg, height 1.83 meters, female, aged 27
# Target weight: 68kg in 30 days
# But this time, a graph instead:
exercise_plan(100, 1.83, 2, 27, 68, 30, return_graph=True)

Exercise plan

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. You can follow guidelines outlined here in case you want to contribute to the project. By contributing to this project, you agree to abide by its terms.

The list of contributors to the original project can be found here.

License

bmigraph was created by Qurat-ul-Ain Azim, Natalie Cho, HanChen Wang, Kelvin Wong. It is licensed under the terms of the MIT license.

Credits

bmigraph was created with cookiecutter and the py-pkgs-cookiecutter template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bmigraph-1.4.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bmigraph-1.4.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file bmigraph-1.4.0.tar.gz.

File metadata

  • Download URL: bmigraph-1.4.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for bmigraph-1.4.0.tar.gz
Algorithm Hash digest
SHA256 05aeac213c60a719a2f07c0261f8abf54fd82cd12401311a4b43ad99db1f3483
MD5 c548ea7dce7c5614ebc11acc55ba4f95
BLAKE2b-256 f5987b1cd0a99b9eaf4df56487a49d5c09a17ebf0f47fd977dfcda5c3c112ce4

See more details on using hashes here.

File details

Details for the file bmigraph-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: bmigraph-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for bmigraph-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e40e701c6bd9e30c5b1313071790f89762e0a5b202b9945245b250c745aad4e
MD5 0d04d7e3f756d657e6b277295a44eb47
BLAKE2b-256 8d1dcf3b49a88b21de4e4a8df26418eaa7fd5d0a0aadbe1b42f88d9f240b8144

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page