Icon

Tutorial-K_​Dummy-coding

<p>This tutorial is part of a series of tutorials on the topic of data preparation (Tutorial_G – Tutorial_O). These tutorials are included in the book, <em>Handbook of Statistical Analysis, AI, and ML Applications (Elsevier Publishers, 2025). </em>These tutorials will guide you to build KNIME workflows to perform common data preparation tasks. You can adapt these workflows easily to load and process your own datasets.</p><p>---</p><p>The publisher has graciously permitted these tutorials to be included on the KNIME Community Hub and has provided the 30% discount code <em>MATH30</em> to purchase the book from https://shop.elsevier.com/books/handbook-of-statistical-analysis/nisbet/978-0-443-15845-2.</p>

This tutorial is part of a series of tutorials on the topic of data preparation (Tutorial_G – Tutorial_O). These tutorials are included in the book, Handbook of Statistical Analysis, AI, and ML Applications (Elsevier Publishers, 2025). These tutorials will guide you to build KNIME workflows to perform common data preparation tasks. You can adapt these workflows easily to load and process your own datasets.

---

The publisher has graciously permitted these tutorials to be included on the KNIME Community Hub and has provided the 30% discount code MATH30 to purchase the book from https://shop.elsevier.com/books/handbook-of-statistical-analysis/nisbet/978-0-443-15845-2.

Tutorial K - Dummy Coding


All data is not created equally. Different than continuous numerical values, categorical data has its own characteristics as they may be represented with textual values or a predefined scale with arbitrary ordering of the categories, which may not necessarily reflect any meaningful relationship between them. Typically, categorical data cannot be handled by machine learning algorithms designed to operate with numerical data only, making encoding an important operation in data preparation.

To resolve for categorical variables, this Tutorial K is about one technique using dummy variables, known as one-hot encoding. A dummy variable is a binary variable coded as 1 or 0 to represent the presence or absence of a variable. The transformation of a variable into dummy variables is indeed a technique used whenever modeling algorithms require numerical data.

There are other techniques used to handle categorical variables. The decision on which category to use depends on the use case. For example, both one-hot encoding and label encoding use numerical values to represent presence or absence; however, they have different properties and are applicable to different use cases.

  • One-hot encoding is suitable for

    1. When the categories do not have any implied ordering or relationship with each other, and each category is treated as a separate entity with no relation to other categories;

    2. When the number of categories is relatively small, so the number of columns does not become very large.


  • On the other hand, label encoding is suitable for:

    1. When the categories imply ordering or relationship with each other, such as with ordinal values (“small,” “medium,” and “large”);

    2. When the number of categories is very large, as each ordinal value can reduce the dimensionality of the data.

Generally, one-hot encoding is more commonly used due to its flexibility, helping to avoid ambiguity and arbitrary ordering problems in machine learning applications.


Review Tutorial_K for more detailed instructions.

Load the file created in Tutorial_J from the Data/ directory:

Tutorial-J_DataCleaning.csv

For target variable, convert the type from Number to String for categorical variable TARGET_B

For categorical variable, RFA_2A, find the one-hot encoded variables.

Rename the new columns with old column name as prefix to the current name.

Filter the column RFA_2R

Nodes

  • No nodes found

Extensions

  • No modules found

Links