{"slug": "before-you-train-the-model-what-my-first-ml-project-taught-me-about-data", "title": "Before You Train the Model: What My First ML Project Taught Me About Data Cleaning", "summary": "A developer's first machine learning project taught them that data cleaning is a critical foundation before model training. After getting poor results from a Kaggle dataset, they learned to inspect data types, handle missing values with median and mode imputation, and convert column types—realizing that preparation is part of building.", "body_md": "When I started my first data analytics and machine learning project, I wanted to get straight to the exciting part: **training a model**.\n\nI downloaded a dataset from Kaggle, chose a basic classification model, trained it, and started making predictions.\n\nBut the results were *strange*.\n\nMy predictions didn't look right, and metrics such as **accuracy** and **ROC-AUC** were much lower than I expected.\n\nMy first thought was:\n\nMaybe I chose the wrong model.\n\nBut the problem started **before the model**.\n\n**I hadn't properly understood or prepared my data.**\n\nInstead of immediately switching algorithms, I went back to the dataset.\n\nI started with:\n\n`df.info()`\n\nThis gave me an overview of my **columns, their data types, and how many non-null values were present**.\n\nNext:\n\n`df.isna().sum()`\n\nThis showed me exactly **where values were missing**.\n\nThen came an important lesson:\n\nFinding missing data and deciding what to do with it are two different things.\n\nDepending on the dataset and what the missing value represents, one option for a numerical column is to fill missing values using the **median**:\n\n`df[\"column\"].fillna(df[\"column\"].median())`\n\nThe median can be useful because it is **less affected by extreme values than the mean**.\n\nFor categorical data, one possible approach is the **mode**:\n\n`df[\"column\"].fillna(df[\"column\"].mode()[0])`\n\n`[0]`\n\n?Because `mode()`\n\nreturns a **Series**. There can be more than one mode, and `[0]`\n\nselects the *first result*.\n\nSometimes, however, filling isn't appropriate at all.\n\nI also learned about:\n\n`df.drop()`\n\n`df.dropna()`\n\nAnd data cleaning wasn't only about **missing values**.\n\nI needed to make sure my columns had the **appropriate data types**.\n\nThat's where tools such as these became useful:\n\n`df.convert_dtypes()`\n\n`df[\"column\"].astype(\"string\")`\n\n`pd.to_datetime(df[\"date\"])`\n\nThese commands weren't the exciting machine-learning model I originally wanted to build.\n\nBut I started realizing something:\n\nThis was part of machine learning too.\n\nThe phrase ** “garbage in, garbage out”** finally started making sense.\n\nA machine-learning algorithm doesn't automatically understand that a column has the wrong data type, that missing values have been handled poorly, or that the data doesn't represent what I think it represents.\n\n**The model learns from what I give it.**\n\nI had been worrying about finding a better algorithm when I hadn't properly prepared the **foundation**.\n\nWhile studying **Genesis 1**, I had written something in my notes:\n\n“Building up bit by bit.”\n\nGenesis 1 doesn't move immediately from a **formless and empty earth** to the finished creation.\n\nThere is progression.\n\n*Light.*\n\n*Separation.*\n\n*Land.*\n\n*Vegetation.*\n\n*The lights in the sky.*\n\n*Living creatures.*\n\n*And finally, humanity.*\n\nThere is **order** to the chapter.\n\nOf course, training a machine-learning model isn't comparable to **God's act of creation**.\n\nBut Genesis 1 made me reflect on something about *how I build*.\n\nI had wanted this:\n\nDataset → Model → Prediction\n\nBut my project actually required:\n\nDataset → Understand → Clean → Prepare → Train → Evaluate\n\nI was rushing toward the **result** while overlooking the work that needed to happen first.\n\nAt first, data cleaning felt like the boring part standing between me and *“real” machine learning*.\n\nI don't see it that way anymore.\n\nPreparation is part of building.\n\nSometimes progress means **checking one column**.\n\nFinding one missing value.\n\nCorrecting one data type.\n\nUnderstanding one problem.\n\nThen moving to the next.\n\n**Build carefully.**\n\n**Build in order.**\n\n*Build bit by bit.*", "url": "https://wpnews.pro/news/before-you-train-the-model-what-my-first-ml-project-taught-me-about-data", "canonical_source": "https://dev.to/weenaithdev/before-you-train-the-model-what-my-first-ml-project-taught-me-about-data-cleaning-16i3", "published_at": "2026-07-25 17:35:14+00:00", "updated_at": "2026-07-25 18:01:31.380865+00:00", "lang": "en", "topics": ["machine-learning", "developer-tools"], "entities": ["Kaggle"], "alternates": {"html": "https://wpnews.pro/news/before-you-train-the-model-what-my-first-ml-project-taught-me-about-data", "markdown": "https://wpnews.pro/news/before-you-train-the-model-what-my-first-ml-project-taught-me-about-data.md", "text": "https://wpnews.pro/news/before-you-train-the-model-what-my-first-ml-project-taught-me-about-data.txt", "jsonld": "https://wpnews.pro/news/before-you-train-the-model-what-my-first-ml-project-taught-me-about-data.jsonld"}}