bmigraph package

Submodules

bmigraph.calculate_bmi module

bmigraph.calculate_bmi.calculate_bmi(weight, height, return_graph=False)[source]

Calculate the body mass index (BMI) based on current weight and height.

Body Mass Index (BMI) is a calculated measure of weight relative to height, defined as body weight in kilograms divided by height in meters squared (Keys et al., 1972). If return_graph is True, an plotly.graph_objects.Figure object instead of a bmi value.

Parameters:
  • weight (float) – Weight, in kilograms. Must have a positive value.

  • height (float) – Height, in meters. Must have a positive value.

  • return_graph (bool) – Whether to return a graph instead of a value

Returns:

If return_graph is False, we get a value of the body mass index. If return_graph is True, we get a plotly.graph_objects.Figure instead that can be saved or shared.

Return type:

float or plotly.graph_objects

Examples

>>> calculate_bmi(100, 1.85, return_graph=False)
>>> 29.218407596785973

bmigraph.exercise_plan module

bmigraph.exercise_plan.exercise_plan(weight, height, sex, age, target_weight, number_of_days, return_graph=False)[source]

Create an exercise plan based on current weight, height, age and target BMI.

The calorie consumption needed each day is computed and a set of activities is suggested accordingly. If return_graph is True, a plotly.graph_objects.Figure object instead of a dictionary.

Parameters:
  • weight (float) – Weight, in kilograms.

  • height (float) – Height, in meters.

  • sex (int) – Sex, used in the Harris–Benedict equation estimation, 1 for male and 2 for female.

  • age (int) – Current age, in years.

  • target_weight (float) – Target weight, in kilograms.

  • number_of_days (int) – Number of days to reach the target weight.

  • return_graph (bool) – Whether to return a graph instead of a dictionary.

Returns:

If return_graph is False, we get a dictionary with key to be different exercises, and the value to be number of minutes (rounded to nearest integer) needed for that activity. Note that each of the activities are associated as an “or”. If return_graph is True, we get a plotly.graph_objects.Figure instead that can be saved or shared.

Return type:

dict or plotly.graph_objects.Figure

Examples

>>> exercise_plan(100, 1.83, 2, 27, 68, 30)
>>> {'Leisure cycling or walking': 213,
>>> 'Moderate rope-jumping': 88,
>>> 'General running': 112,
>>> 'Leisure swimming': 156}

bmigraph.project_bmi module

bmigraph.project_bmi.project_bmi(weight, height, target_bmi, number_of_days, return_graph=False)[source]

Compute average BMI change per week based on current weight, height, age and target BMI.

The average BMI increase or decrease each day is computed. If return_graph is True, a plotly.graph_objects.Figure is given based on forcasted BMI for the target timeframe.

Parameters:
  • weight (float) – Weight, in kilograms.

  • height (float) – Height, in meters.

  • target_bmi (float) – Target BMI.

  • number_of_days (int) – Number of days to reach the target BMI

  • return_graph (bool) – Whether to return a graph instead of a dictionary

Returns:

If return_graph is True, we get the average BMI change per week. If return_graph is False, we get a dictionary with key to be different exercises, and the value to be number of minutes (rounded to nearest integer) needed for that activity. Note that each of the activities are associated as an “or”. If return_graph is True, we get a plotly.graph_objects.Figure instead that can be saved or shared.

Return type:

float or plotly.graph_objects.Figure

Example

>>> project_bmi(weight=108, height=1.88, target_bmi = 28, number_of_days=60)
>>> -0.3

bmigraph.project_calories module

bmigraph.project_calories.project_calories(weight, height, sex, age, pal, target_weight, number_of_days, return_graph=False)[source]

Returns caloric intake per day based in a target weight. Assumption is that the goal is losing weight rather than gaining weight.

Parameters:
  • weight (float) – Current weight in kilograms (kg).

  • height (float) – Current height in meters (m).

  • sex (int) – Sex, used in the Harris–Benedict equation estimation, 1 for male and 2 for female.

  • age (int) – Current age in years.

  • pal (float) – Physcial activity level, can only be one of the four listed values 1.2 for “Little/no exercise” 1.4 for “Light exercise 1-3 times a week” 1.6 for “Moderate exercise 3-5 times a week” 1.75 for “Hard exercise 3-5 times a week”

  • target_weight (int) – Weight goal to be achieved in number_of_days.

  • number_of_days (int) – Number of days allotted to achieve target_weight.

  • return_graph (bool) – Whether to return a graph instead of a float.

Returns:

If return_graph is False, returns a float specifying caloric intake divided by the number of days. If return_graph is True, returns a straight line graph of projected weight loss per day.

Return type:

float or plotly.graph_objects.Figure

Examples

>>> project_calories(100, 1.85, 1, 25, 1.6, 75, 25, return_graph=False)
>>> 2417.0400000000004

Module contents