<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://ynhi-ng.github.io/nhinguyen-ds-portfolio/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ynhi-ng.github.io/nhinguyen-ds-portfolio/" rel="alternate" type="text/html" /><updated>2026-11-26T13:10:44+11:00</updated><id>https://ynhi-ng.github.io/nhinguyen-ds-portfolio/feed.xml</id><title type="html">Nhi Nguyen</title><subtitle>Data mining, visualization, and ML projects &amp; short analyses of data in the news.</subtitle><author><name>Data mining · machine learning · storytelling</name></author><entry><title type="html">Data wrangling before modelling</title><link href="https://ynhi-ng.github.io/nhinguyen-ds-portfolio/data-wrangling/data-wrangling-modelling/" rel="alternate" type="text/html" title="Data wrangling before modelling" /><published>2026-11-14T00:00:00+11:00</published><updated>2026-11-14T00:00:00+11:00</updated><id>https://ynhi-ng.github.io/nhinguyen-ds-portfolio/data-wrangling/data-wrangling-modelling</id><content type="html" xml:base="https://ynhi-ng.github.io/nhinguyen-ds-portfolio/data-wrangling/data-wrangling-modelling/"><![CDATA[<h2 id="summary">Summary</h2>

<p>Data wrangling is usually described as a preparation that happens before any analysis. It is the stage where decisions that shape the result are made.</p>

<h2 id="1-definition">1. Definition</h2>

<p>Data wrangling is the process of acquiring, cleaning, structuring and
enriching raw data into a form that can be used directly for analysis [1].
It is also known as data munging or remediation, and cleaning is only one
part of it [2]. The course I studied breaks it into eight tasks: discovery,
collection, pre-processing, cleaning, transformation, enrichment, validation
and storing [1]. The HBS Online description uses six steps: discovery,
structuring, cleaning, enriching, validating and publishing [2].</p>

<p>The motivation is stated that, analyses are only as reliable as the data behind them [2].</p>

<h2 id="2-objective">2. Objective</h2>

<table>
  <thead>
    <tr>
      <th>Wrangling decision</th>
      <th>How it can affect inference</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Dropping rows with missing values</td>
      <td>Can bias the sample if missingness is not random</td>
    </tr>
    <tr>
      <td>Imputing values</td>
      <td>Can understate variance or hide a data collection fault</td>
    </tr>
    <tr>
      <td>Removing outliers</td>
      <td>Can delete a real effect, or keep an error that skew data distribution</td>
    </tr>
    <tr>
      <td>Choosing the unit of a row</td>
      <td>Changes what the model is actually predicting</td>
    </tr>
    <tr>
      <td>Joining sources</td>
      <td>Can duplicate or lose records and change group sizes</td>
    </tr>
  </tbody>
</table>

<p>There are also some practical obstacles: large volume, quality issues,
diverse sources, complex structures, a lack of standardisation, time cost,
and privacy and security [1]. These are the conditions under which
undocumented decisions pile up.</p>

<h2 id="3-the-protocol">3. The protocol</h2>

<p>I organise the work around the question first, then apply the following steps:</p>

<ol>
  <li><strong>State the question and the unit of analysis.</strong> Note down what each row represents,
  before touching the data. This is the discovery stage, where the data’s suitability and quality are assessed [1].</li>
  <li><strong>Record provenance.</strong> Note the data source, access date and any licence or
permission constraints. For example, listing ethics and privacy[1].</li>
  <li><strong>Profile before changing anything.</strong> Row counts, types, key uniqueness,
missingness and impossible values. I use the validation categories: accuracy, consistency, completeness, range, format, uniqueness[1].</li>
  <li><strong>Pre-specify cleaning rules.</strong> Decide what counts as an error versus a
rare value, and write down the rule before seeing its effect on the
result.</li>
  <li><strong>Transform and enrich with the question in mind.</strong> Normalise, aggregate
or bin only where the method needs it [1]; join other sources only where
they add information the question requires [1][2].</li>
  <li><strong>Validate the output.</strong> Re-run the checks on the final table and compare
against the raw data.</li>
  <li><strong>Store and document process.</strong> Save the result in a suitable
format and make it available with its metadata [1][2].</li>
</ol>

<h2 id="4-documentation-and-reproducibility">4. Documentation and reproducibility</h2>

<p>A wrangling decision is only defensible if someone else can see it: keeping track of validation issues and how they were resolved as part of validation [1]. In practice, I keep a short log in the repository or write down step by step process:</p>

<ol>
  <li>Before each cleaning step, count the rows and affected values.</li>
  <li>Apply the rule.</li>
  <li>Count again, and record the rule, the counts and the reason.</li>
</ol>

<h2 id="5-challenges-to-validity">5. Challenges to validity</h2>

<p>Questions I ask before moving on with the analysis:</p>

<ul>
  <li><strong>Selection:</strong> did cleaning remove a non-random group of records?</li>
  <li><strong>Measurement:</strong> were units, formats and encodings same across sources?</li>
  <li><strong>Leakage:</strong> were any values learned from the full dataset before
splitting? Steps that learn from data, such as imputation values or
scaling, should be fitted on training data only.</li>
  <li><strong>Sensitivity:</strong> do the main findings return the same result if I change a cleaning rule?</li>
</ul>

<h2 id="6-limitations">6. Limitations</h2>

<p>This post summarises two sources: a university course that I studied and one HBS
Online article. It does not review the entire scope on missing data or
data quality, so the validity points above are practical based on experience rather than
a literature-backed framework.</p>

<h2 id="sources">Sources</h2>

<ol>
  <li>University course.</li>
  <li>Stobierski, T. (2021, updated 2023). <a href="https://online.hbs.edu/blog/post/data-wrangling">Data Wrangling: What It Is &amp; Why
It’s Important</a>. Harvard
Business School Online.</li>
</ol>]]></content><author><name>Data mining · machine learning · storytelling</name></author><category term="data-wrangling" /><category term="cleaning" /><category term="pandas" /><category term="R" /><category term="methodology" /><summary type="html"><![CDATA[Data wrangling is where many of an analysis's key decision are made. This post defines it and set out the steps I follow to keep those decisions visible & defensible.]]></summary></entry><entry><title type="html">Welcome to Posts</title><link href="https://ynhi-ng.github.io/nhinguyen-ds-portfolio/meta/welcome-to-posts/" rel="alternate" type="text/html" title="Welcome to Posts" /><published>2026-11-14T00:00:00+11:00</published><updated>2026-11-14T00:00:00+11:00</updated><id>https://ynhi-ng.github.io/nhinguyen-ds-portfolio/meta/welcome-to-posts</id><content type="html" xml:base="https://ynhi-ng.github.io/nhinguyen-ds-portfolio/meta/welcome-to-posts/"><![CDATA[<p>Short notes on data science concepts, personal experiments, and analytical insights—focusing on evidence, methodological limits, and next steps.</p>

<p>Expect write-ups on pattern mining, AI applications in education, and takeaways from my project builds. If you’re looking for case studies write-ups, start with <a href="/nhinguyen-ds-portfolio/projects/">Projects</a>.</p>]]></content><author><name>Data mining · machine learning · storytelling</name></author><category term="meta" /><category term="portfolio" /><category term="writing" /><summary type="html"><![CDATA[Short notes on data science concepts, personal experiments, and analytical insights—focusing on evidence, methodological limits, and next steps.]]></summary></entry></feed>