def ascvd(x_age,
x_cho,
x_hdl,
x_sbp,
x_smo,
x_dia,
verbose=False
):
“”"
Atherosclerotic Cardiovascular Disease
(ASCVD) Risk Estimator Plus
“”"
# Define the coefficients
b_age = 17.114
b_cho = 0.94
b_hdl = -18.92
b_age_hdl = 4.475
b_sbp = 27.82
b_age_sbp = -6.087
b_smo = 0.691
b_dia = 0.874
# Calculate the sum of the products of inputs and coefficients
sum_prod = b_age * np.log(x_age) + \
b_cho * np.log(x_cho) + \
b_hdl * np.log(x_hdl) + \
b_age_hdl * np.log(x_age) * np.log(x_hdl) +\
b_sbp * np.log(x_sbp) +\
b_age_sbp * np.log(x_age) * np.log(x_sbp) +\
b_smo * x_smo + \
b_dia * x_dia
if verbose:
print(f"np.log(x_age):{np.log(x_age):.2f}")
print(f"np.log(x_cho):{np.log(x_cho):.2f}")
print(f"np.log(x_hdl):{np.log(x_hdl):.2f}")
print(f"np.log(x_age) * np.log(x_hdl):{np.log(x_age) * np.log(x_hdl):.2f}")
print(f"np.log(x_sbp): {np.log(x_sbp):2f}")
print(f"np.log(x_age) * np.log(x_sbp): {np.log(x_age) * np.log(x_sbp):.2f}")
print(f"sum_prod {sum_prod:.2f}")
# TODO: Risk Score = 1 - (0.9533^(e^(sum_prod - 86.61) ) )
risk_score = 1 - (0.9533^(e^(sum_prod - 86.61) ) )
return risk_score
tmp_risk_score = ascvd(x_age=55,
x_cho=213,
x_hdl=50,
x_sbp=120,
x_smo=0,
x_dia=0,
verbose=True
)
print(f"\npatient’s ascvd risk score is {tmp_risk_score:.2f}")
Could someone please help me figure out why I get the error message (name ‘e’ is not defined) below when I run the code cells above?
NameError Traceback (most recent call last)
in
5 x_smo=0,
6 x_dia=0,
----> 7 verbose=True
8 )
9 print(f"\npatient’s ascvd risk score is {tmp_risk_score:.2f}")
in ascvd(x_age, x_cho, x_hdl, x_sbp, x_smo, x_dia, verbose)
42
43 # TODO: Risk Score = 1 - (0.9533^(e^(sum_prod - 86.61) ) )
—> 44 risk_score = 1 - (0.9533^(e^(sum_prod - 86.61) ) )
45
46 return risk_score
NameError: name ‘e’ is not defined