Blood pressure

The blood pressure measures the amount of force per unit area that the blood exerts on the blood vessel walls. Blood pressure consists of two numbers – the systolic blood pressure (blood pressure during the systolic phase of the heartbeat) and the diastolic blood pressure (blood pressure during the diastolic phase). Normal blood pressure is usually somewhere between 110 to 120 mmHg for the systolic blood pressure and 70 to 80 mmHg for the diastolic blood pressure. Elevated blood pressure is called hypertension. The most common cause of elevated blood pressure is essential hypertension, which is primarily genetic (but multifactorial). Low blood pressure is called hypotension. Both hypertension and hypotension have complex etiologies that are often difficult to identify.

In our dataset, systolic and diastolic blood pressure are in separate columns (BPSYS and BPDIAS, respectively). First, we process the systolic blood pressure by converting it to a numeric type and mean imputing the missing values as we have done already for other columns:

X_train.loc[:,'BPSYS'] = X_train.loc[:,'BPSYS'].apply(pd.to_numeric)
X_test.loc[:,'BPSYS'] = X_test.loc[:,'BPSYS'].apply(pd.to_numeric)

X_train = mean_impute_values(X_train,'BPSYS')
X_test = mean_impute_values(X_test,'BPSYS')

Diastolic blood pressure is a bit more complex. The value 998 means that the pressure was PALP, meaning that it was too low to be detected by a sphygmamometer but high enough to feel by touch (palpation). After we convert it to a numeric type, we will substitute a numeric value of 40 for the PALP values:

X_train.loc[:,'BPDIAS'] = X_train.loc[:,'BPDIAS'].apply(pd.to_numeric)
X_test.loc[:,'BPDIAS'] = X_test.loc[:,'BPDIAS'].apply(pd.to_numeric)

We write a new function called mean_impute_bp_diast() that does the conversion of PALP values to 40 and the missing values to the mean:

def mean_impute_bp_diast(data,col): 
temp_mean = data.loc[(data[col] != 998) & (data[col] != -9), col].mean()
data.loc[data[col] == 998, col] = 40
data.loc[data[col] == -9, col] = temp_mean
return data

X_train = mean_impute_values(X_train,'BPDIAS')
X_test = mean_impute_values(X_test,'BPDIAS')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset