Warning: this content is older than 365 days. It may be out of date and no longer relevant.

The Predictive Analytics Process- Preparing Data

In the last post, we examined the basics of extracting data from various data stores and the different types of datasets we have access to. Let’s now look at the process of preparing data.

The Predictive Analytics Process: Preparing Data 1

Three Data Challenges

In the preparation of our data, we typically face three challenges:

  • Missing data
  • Corrupted data
  • Irrelevant data

To counter these challenges, we should be familiar with three techniques to overcome these challenges:

  • Imputation
  • Anomaly detection
  • Feature engineering

Let’s dig in.

Dealing with Missing Data

Missing data occurs when something goes wrong with our analytics. Perhaps we accidentally deleted a tracking code when migrating software or changing our website. Perhaps a third party omitted the data. Whatever the case may be, we need to deal with the problem.

First, we quantify how much data is missing. The general rule of thumb among most statistical software package developers is that a dataset becomes unusable when the amount of missing data exceeds 5%. If, for example, we accidentally deleted our Google Analytics tracking code off our website, we would still have mostly usable data as long the total amount of missing data didn’t exceed 18 calendar days per 365 day period.

Second, if the dataset is still usable, we need to patch the holes in it. In most statistical software packages, libraries exist to help us bridge these gaps. I use R, and the recommended default package for recovering data is called Hmisc. With it, we feed as much data as we have for a time series, and the software attempts to repair it.

For example, if we have a period of time like 4 days where we messed up our Google Analytics data, we’d use Hmisc and all other data available during that period (like email marketing data, social media data, etc.) to help Hmisc impute the missing data.

Dealing with Corrupted Data

Corrupted data occurs when our data goes awry. A simple example is if we installed two copies of our web analytics tracking code on our site. We’d have double the data, but the business results wouldn’t validate the doubling of traffic.

Corruption in marketing analytics also extends to “black swans”, random, unplanned, and unrepeatable occurrences.

We detect corrupted data with visualization and anomaly detection. By charting or graphing our data, we identify anomalies. Once identified, we will choose whether to incorporate them into our models or not.

For example, a couple years ago, I saw a massive one-day spike in my Google Analytics data from a Reddit post that went wild. That post was off-topic from what I write about, but it severely distorted traffic for a day. I choose to simply delete that data when I build predictive analytics models and use the imputation methods above to compensate for it.

Dealing with Irrelevant Data

Few things hose predictions (and many statistical methods) like irrelevant data. While missing data can break models and corrupted data can mislead models, irrelevant data makes models completely unusable.

The antidote to irrelevant data is feature engineering, in which we use extensive testing to determine whether or not a variable is relevant. The most common technique used for variable identification is the random forest, in which our software creates thousands or tens of thousands of simulations using every possible combination of variables, then determines what’s relevant and what’s not.

Once we identify what’s relevant and what’s not – and good judgement is equally important as machine learning technology – we remove the irrelevant data to improve our model.

For example, I was doing some analysis of my Google Analytics data and also had social media data alongside it. When I built a random forest of all my variables, virtually all of the social media data – likes, comments, etc. – were irrelevant in terms of what drove business impact. So instead of building a model using all data, I built a model using just the data that mattered most. That in turn changed my social media strategy to focus on one particular set of actions, rather than everything.

Next: Identify

Now that we have clean, usable data, we next look at what to predict. Stay tuned!


You might also enjoy:


Want to read more like this from Christopher Penn? Get updates here:

subscribe to my newsletter here


AI for Marketers Book
Take my Generative AI for Marketers course!

Analytics for Marketers Discussion Group
Join my Analytics for Marketers Slack Group!