Target encoding (also called mean encoding) is a feature engineering technique that replaces categorical values with the mean of the target variable for each category. This converts categorical features into numeric features that capture the relationship between the category and the target, making them usable by models that require numeric input.
Given a list of categorical values and corresponding target values, replace each category with the mean target value for that category.
Return one floating-point encoding for each input category.
Input: categories = ["cat", "dog", "cat", "dog"], targets = [1, 2, 3, 4]
Output: [2.0, 3.0, 2.0, 3.0]
Explanation: Cat targets average to 2 and dog targets average to 3.
Input: categories = ["a", "b", "c", "a", "b", "c"], targets = [1, 2, 3, 4, 5, 6]
Output: [2.5, 3.5, 4.5, 2.5, 3.5, 4.5]
Track a target sum and count for every category.
Create category means, then map the original category sequence through them.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Target encoding (also called mean encoding) is a feature engineering technique that replaces categorical values with the mean of the target variable for each category. This converts categorical features into numeric features that capture the relationship between the category and the target, making them usable by models that require numeric input.
Given a list of categorical values and corresponding target values, replace each category with the mean target value for that category.
Return one floating-point encoding for each input category.
Input: categories = ["cat", "dog", "cat", "dog"], targets = [1, 2, 3, 4]
Output: [2.0, 3.0, 2.0, 3.0]
Explanation: Cat targets average to 2 and dog targets average to 3.
Input: categories = ["a", "b", "c", "a", "b", "c"], targets = [1, 2, 3, 4, 5, 6]
Output: [2.5, 3.5, 4.5, 2.5, 3.5, 4.5]
Track a target sum and count for every category.
Create category means, then map the original category sequence through them.
Sign in to take notes on this problem
Accepts: array
Accepts: array