Skip to content

Independent AI & deep-tech news

Data Science

Data Preparation In Machine Learning Projects – Basics To The Implant

Data Preparation In Machine Learning Projects – Basics To The Implant
On this page
  1. Key takeaways
  2. What is data preparation?
  3. What are the common data preparation tasks?
  4. Is data preparation done blindly?
  5. How do you decide which data preparation methods to use?
  6. Why is data preparation iterative?
  7. Frequently asked questions
  8. Conclusion

Data preparation is the step in a predictive modeling project that turns raw data into a form a machine learning algorithm can learn from. It is often one of the hardest steps, because every dataset is different and the right techniques depend on the problem, the data and the algorithms you plan to use.

Key takeaways

  • Data preparation converts raw data into a form that is better suited to modeling.
  • Common tasks include data cleaning, feature selection, data transforms, feature engineering and dimensionality reduction.
  • The steps before and after preparation (defining the problem and evaluating models) guide which techniques to try.
  • The overall goal is to expose the underlying structure of the problem to the learning algorithms.
  • Predictive modeling is iterative, so preparation is revisited as you learn more.

What is data preparation?

In a predictive modeling project, such as regression or classification, raw data usually cannot be used directly. There are several reasons for this:

  • Machine learning algorithms require numeric input.
  • Some algorithms place requirements on the data, such as a particular distribution.
  • Errors, missing values and statistical noise in the data may need to be corrected.
  • Complex nonlinear relationships may be hidden in the data and need to be brought out.

Raw data must therefore be pre-processed before it is used to fit and evaluate a model. This step is called data preparation, though it goes by other names, including data cleaning, data wrangling, data pre-processing and feature engineering. Several of these terms are better understood as sub-tasks of the wider preparation process.

Put simply, data preparation means transforming raw data into a form that is more suitable for modeling. How that is done depends on your data, the objectives of the project and the algorithms you use.

What are the common data preparation tasks?

Although each project is specific, a handful of tasks appear again and again during this stage.

Task What it does
Data cleaning Identifies and corrects errors or mistakes in the data.
Feature selection Identifies the input variables that are most relevant to the task.
Data transforms Changes the scale or distribution of variables.
Feature engineering Derives new variables from the available data.
Dimensionality reduction Creates compact projections of the data with fewer input variables.

Each of these tasks is a field of study in its own right, with specialized techniques and algorithms.

Is data preparation done blindly?

No. In some cases the need is obvious: variables must be encoded or converted, for example turning strings into numbers, before an algorithm can use them. In other cases the benefit is less clear. Scaling a variable may or may not help a given algorithm, so it often has to be tested.

The guiding idea is to find the best way to expose the underlying structure of the problem to the learning algorithms. Nobody knows that structure in advance. If they did, there would be no need for a learning algorithm to discover it and make skillful predictions. Searching for it is effectively a search for the best data preparation and the best-performing algorithms at the same time.

This can be harder than it sounds. Many input variables may call for different preparation, and different subsets of variables may need different techniques. With so many options, each with its own settings, the choice can feel overwhelming. The stages that come before and after preparation help narrow it down.

How do you decide which data preparation methods to use?

In the abstract this is a difficult question. It becomes more manageable when data preparation is viewed in the context of the whole project, because the steps on either side of it point to the techniques worth trying.

What happens before data preparation?

The stage before preparation is about understanding the problem. It can involve sub-tasks such as:

  • Collecting data from the problem domain.
  • Discussing the project with subject matter experts.
  • Choosing which variables will be inputs and which will be outputs of the predictive model.
  • Reviewing the data that has been collected.
  • Summarizing the data with statistical methods.
  • Visualizing the data with charts and plots.
  • Recording what has been learned about the data, which feeds into choosing and building preparation techniques.

What happens after data preparation?

Model evaluation also influences preparation. It can involve sub-tasks such as:

  • Choosing a performance metric to assess the predictive skill of a model.
  • Choosing a model evaluation procedure.
  • Selecting the algorithms to test.
  • Tuning algorithm hyperparameters.
  • Combining predictive models into ensembles.

What you learn about which algorithms work well can in turn guide how preparation is configured and chosen. For example, the choice of algorithm can impose requirements on the type and form of the input variables. That might mean variables need a particular probability distribution, correlated inputs should be reduced, or variables that are not relevant to the target should be removed.

The choice of performance metric can also affect how the target variable is prepared. If a regression model is judged by its prediction error in a specific unit of measure, any scaling applied to the target variable has to be reversed before the error is calculated.

Why is data preparation iterative?

These examples show that data preparation is a significant stage in a predictive modeling project, but not an isolated one. It is strongly influenced by the work done both before and after it. That is why predictive modeling projects are so iterative: findings from modeling send you back to adjust preparation, and findings from preparation change how you model.

Frequently asked questions

What is data preparation in machine learning?

It is the process of converting raw data into a form better suited for modeling. It covers tasks such as cleaning, feature selection, transforms, feature engineering and dimensionality reduction.

Is data preparation the same as data cleaning?

No. Data cleaning, which means finding and fixing errors in the data, is one sub-task of data preparation. Preparation is the broader process.

Why can’t raw data be fed straight into a model?

Algorithms generally need numeric input, may impose requirements on the data, and can be misled by missing values, errors and noise. Raw data often fails on one or more of these points.

Which data preparation techniques should I use?

There is no universal answer. Understanding the problem and the data, and the algorithms and metrics you plan to use, indicates which techniques are worth testing.

Conclusion

Data preparation shapes raw data so that learning algorithms can find the structure in it. The techniques depend on the problem, the data and the algorithms, and the stages around preparation help decide which to try. Treating the whole project as an iterative loop gives the best chance of finding a preparation approach that works.

Written by

Manika Sharma

16 articles on DeepTechBytes