%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('../data/SAheart/SAheart.data', index_col = 0)
df['famhist'] = df['famhist'].map({'Present': 1, 'Absent': 0})
# These columns are not used in the book.
df.pop('adiposity')
df.pop('typea')
df_y = df.pop('chd')
df.head()| sbp | tobacco | ldl | famhist | obesity | alcohol | age | |
|---|---|---|---|---|---|---|---|
| row.names | |||||||
| 1 | 160 | 12.00 | 5.73 | 1 | 25.30 | 97.20 | 52 |
| 2 | 144 | 0.01 | 4.41 | 0 | 28.87 | 2.06 | 63 |
| 3 | 118 | 0.08 | 3.48 | 1 | 29.14 | 3.81 | 46 |
| 4 | 170 | 7.50 | 6.41 | 1 | 31.99 | 24.26 | 58 |
| 5 | 134 | 13.60 | 3.50 | 1 | 25.99 | 57.34 | 49 |
