glucopy.metrics.grade#
- glucopy.metrics.grade(df: DataFrame, percentage: bool = True, unit: str = 'mg/dL')[source]#
Calculates the contributions of the Glycaemic Risk Assessment Diabetes Equation (GRADE) to Hypoglycaemia, Euglycaemia and Hyperglycaemia. Or the GRADE scores for each value.
\[GRADE = 425 * [\log_{10}(\log_{10} (X_i) + 0.16)]^2\]\(X_i\) is the glucose value in mmol/L at time i.
The GRADE contribution percentages are calculated as follows:
\begin{align*} \text{Hypoglycaemia %} &= 100 * \frac{\sum \text{GRADE}(X_i < 3.9 [\text{mmol/L}])}{\sum \text{GRADE}(X_i)} \\ \text{Euglycaemia %} &= 100 * \frac{\sum \text{GRADE}(3.9 [\text{mmol/L}] \leq X_i \leq 7.8 [\text{mmol/L}])}{\sum \text{GRADE}(X_i)} \\ \text{Hyperglycaemia %} &= 100 * \frac{\sum \text{GRADE}(X_i > 7.8 [\text{mmol/L}])}{\sum \text{GRADE}(X_i)} \end{align*}- Parameters:
df (pandas.DataFrame) – DataFrame containing the CGM values. The dataframe must contain ‘CGM’ column present in
glucopy.Gframe.data
.percentage (bool, default True) – If True, returns a pandas.Series of GRADE score contribution percentage for Hypoglycaemia, Euglycaemia and Hyperglycaemia. If False, returns a list of GRADE scores for each value.
unit (str, default 'mg/dL') – Unit of the CGM values. Can be ‘mg/dL’ or ‘mmol/L’.
- Returns:
grade – Series of GRADE score contribution percentage for Hypoglycaemia, Euglycaemia and Hyperglycaemia. Or a list of GRADE scores for each value.
- Return type:
pandas.Series | numpy.ndarray
Notes
This function is meant to be used by
glucopy.Gframe.grade()