6. More Tools and Techniques for Evaluating Regression Models
Activity 6.01: Finding Important Variables for Predicting Responses to a Marketing Offer
Solution:
Perform the following steps to achieve the aim of this activity:
- Import pandas, read in the data from offer_responses.csv, and use the head function to view the first five rows of the data:
import pandas as pd
df = pd.read_csv('offer_responses.csv')
df.head()
Note
Make sure you change the path (emboldened) to the CSV file based on its location on your system. If you're running the Jupyter notebook from the same directory where the CSV file is stored, you can run the preceding code without any modifications.
You should get the following output:
Figure 6.22: The first five rows of the offer_responses data
- Extract the target variable (y) and the predictor variable (X) from the data:
X = df[['offer_quality',\
        'offer_discount',\
  &...