## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Creating a predictive model using logistic regression

Logistic regression is a statistical technique used to predict a binary outcome, for example, purchase/no-purchase.

For this recipe, we are going to use the Heart dataset from An Introduction to Statistical Learning with Applications in R.

## How to do it…

1. First, import the Python libraries that you need:
```import pandas as pd
import numpy as np
import matplotlib as plt
import matplotlib.pyplot as plt
%matplotlib inline```
2. Next, define a variable for the heart data file, import the data, and view the top five rows:
`data_file = '/Users/robertdempsey/Dropbox/private/Python Business Intelligence Cookbook/Data/ISL/Heart.csv' heart = pd.read_csv(data_file, sep=',', header=0, index_col=0, parse_dates=True, tupleize_cols=False, ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required