What is “one-hot encoding” in machine learning?
Answer:
Explanation:
One-hot encoding is a technique used in machine learning to represent categorical variables as binary vectors. Each category in the variable is represented as a vector, where only one element is “hot” (i.e., set to 1), and all other elements are “cold” (i.e., set to 0).
This transformation allows machine learning models to work with categorical data in a format that they can process, as most models require numerical input. One-hot encoding is widely used in tasks such as classification and natural language processing.
For example, if a categorical variable has three possible values (e.g., “red,” “blue,” and “green”), each value is represented by a three-element vector: [1, 0, 0], [0, 1, 0], or [0, 0, 1]. This makes the data easier to work with for machine learning algorithms.