Skip to main content

A BMI calculator and more!

Project description

bmigraph codecov Documentation Status CI/CD 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.

The latest documentation of the package, hosted on Read the Docs, can be found here.

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.1.tar.gz (7.9 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.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bmigraph-1.4.1.tar.gz
  • Upload date:
  • Size: 7.9 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.1.tar.gz
Algorithm Hash digest
SHA256 df68d43f46b5a2357e42ebf77d7be80990823f883df7c47c0692094913c7cce1
MD5 e41b76fdce1145f8ded8e0b6ea25d548
BLAKE2b-256 979142cca1082a71aeef18d3f0f971f616075fba223aa7822b91376ee6cb33c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bmigraph-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bde11c25a4cecb8187154f2b970c3ca66b87eecd0683b925fa87e799cae88a2
MD5 7b4e80a10b3eca199c2aac92a5cee170
BLAKE2b-256 1fb823e326f5aec6f7ba74fd4f8c9d259f769a2ee92b6f2124a992c804c4f679

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