Skip to content

Data Preparation for Machine Learning: Most of the Job

Irish tax guides · AI and technology · 24 November 2026 · 4 min read

Data preparation is the work of turning a messy export from your accounting or sales system into a clean table a model can learn from. In practice it takes most of the project time, and it decides the quality of the result far more than the choice of model. The core steps are: remove duplicates, deal with missing values, fix types and outliers, build useful features, avoid leakage and split the data before you train.

Why does preparation take most of the time?

Business data is created for running the business, not for analysis. Names are typed three different ways, dates arrive as text, one branch records VAT-inclusive prices and another VAT-exclusive, and a field that was optional for five years is blank. A model cannot guess what you meant. It will happily learn from the errors and give you a confident wrong answer. A model trained on poor data is worse than no model, because it looks scientific.

This is the same discipline as clean bookkeeping: garbage in, garbage out. If you want a wider view of analysis for finance staff, see data analytics for finance teams.

What are the steps, in order?

  1. Define the question and the unit. One row per invoice, per customer or per month? Decide first, because every other step depends on it.
  2. Look before you clean. Count rows, list column types, count blanks and check the smallest and largest values in every number column.
  3. Remove duplicates. Same invoice number twice, or the same payment exported from two systems.
  4. Handle missing values. Delete the row if the missing field is essential, fill with the median or a standard value if it is minor, or add a column that records that it was missing.
  5. Fix types and units. Dates as dates, euro as numbers, one currency, one VAT basis.
  6. Treat outliers. A €9,000,000 invoice in a café's data is probably a typing error. A genuine large order should stay, perhaps flagged.
  7. Create features. Days to pay, month, customer age in years, share of earlier invoices paid late.
  8. Encode categories. Turn text groups such as customer type into yes or no columns.
  9. Split the data. Set aside test rows before you tune anything.

Worked example: a Galway wholesaler's sales export

Dara exports 12,000 invoice lines from his accounting system to predict which customers will cut their orders. His checks show:

  • 300 exact duplicate lines (same invoice number and amount, from a re-import).
  • 450 lines with a missing invoice date.
  • 86 lines where the amount was typed with an extra zero, found by sorting the amount column.

He removes the duplicates: 12,000 - 300 = 11,700. He cannot use lines with no date for a time-based model, so he removes them too: 11,700 - 450 = 11,250 lines. That is 93.75% of the original (11,250 / 12,000). For the 86 mistyped amounts he checks the original invoices and corrects them rather than deleting them, since each one is a real sale. Only then does he build features. This took him an afternoon. Training the model took ten minutes.

If a quick step in Excel is enough, Python for accountants shows how to repeat the same cleaning every month with a script, so the next export is clean in seconds.

What is data leakage and why does it ruin results?

Leakage means a feature contains information that would not be available at the time you need the prediction. If you predict late payment and include "number of reminders sent", you are using the future: reminders only exist for late invoices. The model scores brilliantly in testing and fails in real use. Ask for each column: would I know this on the day I make the prediction?

A second form of leakage is cleaning the whole file, for example filling blanks with the average, before the train and test split. The test data then influences the training data. Split first, then compute the fill values from the training rows only.

How do you keep the data legal and safe?

  • Keep only the columns you need. Names, addresses and PPS numbers rarely help a model.
  • Replace identifiers with a code and keep the key file separate and protected.
  • Record where the data came from and what you changed, so that someone else can repeat it.
  • Delete working copies when the project ends, following your data retention policy.
  • Check that your use of the data matches why you collected it, as explained in GDPR for small businesses.

The Strategic Management programme teaches the decision side of analysis: which questions deserve a data project, and how to read the results, so that you can direct the work with confidence.

Key points

  • Preparation takes most of the time and drives most of the quality.
  • Remove duplicates, fix types, handle blanks and review outliers before modelling.
  • Split the data before you fill, scale or tune anything.
  • Use only facts that exist on the day you need the prediction.
  • Keep a note of every change and keep personal data to the minimum.

Questions people ask

Why does data preparation take so long in machine learning?
Business data is created to run the business, so it contains duplicates, blanks, mixed formats and typing errors. Fixing these needs checking against source documents and sensible decisions, and a model trained on faulty data gives faulty answers, so the time spent is worth it.
How should I handle missing values in a dataset?
Delete the row if the missing field is essential, fill a minor gap with the median or another standard value, or add a flag column showing that it was missing. Decide using the training rows only, and never invent values that you cannot justify.
What is data leakage in machine learning?
Leakage is when the model is given information it would not have at the time of a real prediction, such as reminders sent after an invoice is overdue. It makes test results look excellent and real performance poor. Check every column by asking whether you would know it on the day.
Can I use customer data to train a model under GDPR?
Often yes, if you have a lawful basis, the use fits the purpose the data was collected for, and you keep to the minimum needed. Remove names and identifiers where you can, store the data securely and delete working copies when the project ends.

Know someone this would help? Share it.