Book Image

Data Science for Marketing Analytics - Second Edition

By : Mirza Rahim Baig, Gururajan Govindan, Vishwesh Ravi Shrimali
Book Image

Data Science for Marketing Analytics - Second Edition

By: Mirza Rahim Baig, Gururajan Govindan, Vishwesh Ravi Shrimali

Overview of this book

Unleash the power of data to reach your marketing goals with this practical guide to data science for business. This book will help you get started on your journey to becoming a master of marketing analytics with Python. You'll work with relevant datasets and build your practical skills by tackling engaging exercises and activities that simulate real-world market analysis projects. You'll learn to think like a data scientist, build your problem-solving skills, and discover how to look at data in new ways to deliver business insights and make intelligent data-driven decisions. As well as learning how to clean, explore, and visualize data, you'll implement machine learning algorithms and build models to make predictions. As you work through the book, you'll use Python tools to analyze sales, visualize advertising data, predict revenue, address customer churn, and implement customer segmentation to understand behavior. By the end of this book, you'll have the knowledge, skills, and confidence to implement data science and machine learning techniques to better understand your marketing data and improve your decision-making.
Table of Contents (11 chapters)
Preface

5. Predicting Customer Revenue Using Linear Regression

Activity 5.01: Examining the Relationship between Store Location and Revenue

Solution:

  1. Import the pandas, pyplot from matplotlib, and seaborn libraries. Read the data into a DataFrame called df and print the top five records using the following code:

    import pandas as pd

    import matplotlib.pyplot as plt, seaborn as sns

    df = pd.read_csv('location_rev.csv')

    df.head()

    Note

    Make sure you change the path (highlighted) 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 modification.

    The data should appear as follows:

    Figure 5.35: The first five rows of the location revenue data

    You see that, as described earlier, you have the revenue of the store, its age, along with various fields about the location of the store. From the top five records, you get a sense of the order of the values...