liveBook · Manning

Non-binary categorical feature

As explained in Grokking Machine Learning

A categorical feature whose possible values include more than two distinct classes.

A non-binary categorical feature has more than two possible classes, such as dog, cat, or bird. Decision trees handle it by asking one yes-or-no question for each class. section 9.3

To choose the best split:

  • Turn each class into a binary question, such as “Is the animal a dog?” section 9.3
  • Compare the resulting splits with accuracy, Gini index, or entropy. section 9.3
  • Call this transformation one-hot encoding. section 9.3

Dog, cat, or bird

For an animal labeled dog, the questions “Is it a dog?”, “Is it a cat?”, and “Is it a bird?” produce yes, no, and no.

How Grokking Machine Learning covers it

How deep it goes
Explains the binary-question transformation, split selection metrics, and one-hot encoding, but does not develop implementation code.
Examples
Uses dog, cat, and bird classes with corresponding yes-or-no questions.
What it assumes
Assumes familiarity with binary categorical features and decision-tree splitting.
What you can do after
Apply decision-tree splitting to categorical features with more than two classes.
How it connects
Connects non-binary categorical features to decision trees, one-hot encoding, accuracy, Gini index, and entropy.

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.