Let the data speak for itself: Do you truly know your data before building a machine learning model?

Most of us focus on algorithms first when starting a machine learning project. I used to do exactly that. However, taking the time to understand the data before building a model is a crucial part of a healthy machine learning process. In this article, I will start with fundamental concepts such as "What is data?" and discuss why quality data and the processes for improving data quality are important

What is data?
Data, in general, consists of raw observations. In this form, it may not be meaningful, but with the right context and analysis, it can gain value and become meaningful information. It can support decision-making processes. A simple example of data is the number "27." While it is nothing more than a number on its own, it gains meaning and becomes meaningful information within a context. For example, the information "The average temperature for the week is 27 degrees."
High-quality and accurately collected data supports decisions being based not only on intuition but also on statistical evidence.A dataset, in its simplest definition, is a collection of raw data organized into rows and columns suitable for analysis. Each row represents an observation, and each column represents a characteristic of that observation. Today, data is not only the focus of data science, but also of fields like machine learning and artificial intelligence that require large amounts of training data. Large organizations need and collect vast volumes of training data to develop the right machine learning models and improve their performance.


Why is having a dataset not enough?
A dataset is essential for organizing data more effectively, but...Having a dataset doesn't mean it's ready to use. In fact, possessing a dataset is not the same as understanding it. We don't yet know the structure, quality, or problems of our dataset; in other words, we don't know the dataset.

What does it really mean to truly know a dataset?
We cannot understand a dataset simply by glancing at it. Understanding requires data literacy. The ability to read, interpret, analyze, and question data, draw reliable conclusions, and effectively communicate those conclusions to others, forms a strong data literacy foundation for anyone who works with data.

Why does understanding the data come before model selection?
There's a very simple logic to this:The resulting model is no better than, or at best equal to,the quality of the data it's fed.”.
Let me explain this with a well-known example. Imagine you are in the kitchen, and even if you have the best oven in the world (a machine learning model) in front of you, if the ingredients (data) you put into the recipe are spoiled, moldy, or incorrect, it is difficult to produce a satisfying meal. We see the same logic in mathematics. As you know, the output of a mathematical function
depends on its input. The result a model will produce also depends on its input. Higher quality input yields higher quality output.
This is why simply having a dataset isn't always enough; the quality and reliability of your dataset are also crucial for developing trustworthy AI models. Therefore, improving data quality can be considered one of the key considerations before model development.
Fortunately, data quality isn't a matter of chance. With the right methods, data can be made more reliable and better prepared for analysis.

How to Prepare Data for Model Training?
There are powerful, standardized steps in data science to prepare raw data for model training: Exploratory Data Analysis (EDA) to decipher the data's anatomy, Data Cleaning to remove missing and erroneous records, and Feature Engineering to give the data new meaning. Let's take a closer look at these steps that prepare the data for the model by bringing it to near perfection.
Almost every dataset contains patterns waiting to be discovered. Therefore, when starting to work with a new dataset, it's a good idea to prioritize understanding the data. This allows you
to observe the structure within the data and make initial inferences about it.
So what is Exploratory Data Analysis (EDA)?
As stated in the following sentence, which describes EDA's approach:Let the data speak for itself! This sentence summarizes EDA's core philosophy.
Basically,it makes it easier for us to see the characteristic features within the data.This can mean having insights that will help us throughout the entire process.
Exploratory data analysis is an iterative process, and most real-world projects typically follow this structure:
First, the overall structure of the dataset is examined; the number of observations and variables, data types, and basic characteristics are understood. Then, problems that may affect data quality, such as missing values, duplicate records, or inconsistent categories, are investigated. Distributions, outliers, and relationships between variables are explored with the help of numerical inferences and visualizations. Finally, all the observations obtained are combined to form initial inferences about the data and develop ideas that will guide the next steps.
To make this more concrete, let's proceed with an example dataset. In real projects, datasets can be much larger and more complex; the methods applied may vary depending on the characteristics of the dataset, the business problem, and the requirements of the model, but the basic approach remains the same.
Our sample dataset includes variables such as age, customer review, salary, and purchase status.
Let's illustrate this. First, we try to understand the data by visualizing the age distribution of customers according to their purchasing behavior. This allows us to obtain our initial
observations on issues such as whether purchasing behavior differs in specific age groups. 


During EDA, we began to understand the structure of the dataset and identify areas requiring attention. The next step is Data Cleaning, which is the phase of working on the identified problems.

What is data cleaning ?
Data cleaning, in general, is a fundamental process encompassing steps such as removing duplicate records and inconsistent values, organizing data types, evaluating outliers if necessary, and addressing missing values. Thus, by organizing the data discovered with EDA, we can make it more usable and of higher quality.

For example, let's assume our mini dataset contains missing values ​​in the "Age" and "Review" variables. During the data cleaning phase, these missing observations are filled in using appropriate methods, making the dataset more reliable for analysis and modeling. Since missing observations can affect the analysis result and many machine learning models cannot work with missing observations, they should be addressed appropriately for the situation and dataset before model training.

Data cleaning is a crucial step in ensuring data accuracy and reliability. The goal is not just to fix problems.Data cleaning helps create a reliable and consistent dataset for both analyses and models, which can support the efficiency of data-driven decision-making.

After exploring and manipulating the data, the next step is feature engineering.

What is Feature Engineering?
We identified potential problems in the data, addressed the truly problematic areas, and are now able to make updates and changes to the data. Since some features within the data may not carry sufficient information on their own, we can make updates such as generating new information from existing features or removing unnecessary features.We can help the model learn from more meaningful patterns.. 

Our dataset consists of customer reviews expressed in categorical terms such as "Poor," "Average," and "Good." Since many machine learning algorithms cannot work directly with textual categories, these values ​​are converted into their numerical equivalents. This conversion is a fundamental example of feature engineering.

In addition to all these standards, one of the most useful habits I've developed in my own work is to take notes on the insights gained, to constantly question the data in order to understand it, and to create a data glossary.

What is “Garbage In Garbage Out” ?
We've seen that data quality is extremely important. The Garbage In Garbage Out (GIGO) concept beautifully illustrates why data should be of the highest possible quality. It represents the idea that "defective input data will produce equally defective output."

An algorithm cannot magically fix “bad” data; it only learns from what you give it.

Conclusion
In conclusion, healthy machine learning projects begin not with training models, but with understanding the data. It is believed that correctly understanding the data can have a greater impact than model selection.

In your next machine learning project, try taking the time to really get to know your data before moving on to the model!

Ebru Arık