Questions tagged [categorical-encoding]
The categorical-encoding tag has no usage guidance.
82
questions
8
votes
5
answers
6k
views
How do I encode the categorical columns if there are more than 15 unique values?
I'm trying to use this data to make a data analysis report using regression. Since regression only allows for numerical types, I then need to encode the categorical data. However, most of these have ...
5
votes
2
answers
6k
views
How to handle categorical variables with Random Forest using Scikit Learn?
One of the variables/features is the department id, which is like 1001, 1002, ..., 1218, etc. The ids are nominal, not ordinal, i.e., they are just ids, department 1002 is by no means higher than ...
5
votes
1
answer
3k
views
Target encoding with KFold cross-validation - how to transform test set?
Let's say I have a categorical feature (cat):
...
4
votes
1
answer
725
views
Decision Tree only splits to the left
I can’t really understand, why my decision tree only splits to the left.
I originally have 2 categorical features (further named feature 0 and 1), which I concat to one feature since feature 1 is ...
4
votes
1
answer
529
views
On gradient boosting and types of encodings
I am having a look at this material and I have found the following statement:
For this class of models [Gradient Boosting Machine algorithms] [...] it is both safe and significantly
more ...
4
votes
1
answer
3k
views
Strategies to encode categorical variables with many categories
I was going over the Kaggle competitions IEEE,Categorical Feature Encoding Challenge and one of the ways in which categorical variables have been handled is by replacing the variables by the ...
3
votes
2
answers
1k
views
Choose-many categorical features: alternatives to one-hot encoding?
I'm building a model to predict the lifetime value of a client based on the relational data we have on them. The user table has a bunch of one-to-many child tables that might be predictive. Grossly ...
3
votes
1
answer
61
views
One hot encoding of target variable containing classes 1 to 9 not including zero
While predicting a solution for a sudoku puzzle using CNN, the target variable should predict values from 1 to 9 for all the 81(9*9) values in the puzzle. Hence the target value shape is (81,9).
Using ...
3
votes
1
answer
1k
views
Encoding and cross-validation
Recently I've been thinking about the proper use of encoding within cross-validation scheme. The customarily advised way of encoding features is:
Split the data into train and test (hold-out) set
Fit ...
3
votes
0
answers
76
views
What is the concept behind the categorical-encoding used in the CatBoost benchmark problems?
I'm working through CatBoost quality benchmark problems (here). I'm particularly intrigued by the methodology adopted to convert categorical features to numerical values as described in the ...
2
votes
1
answer
31
views
How do I get the mean values that are greater than .5 for my model?
I am trying to build a classification model. One of the variables called specialty has 200 values. Based on a previous post I saw, I decided I wanted to include the values that have the highest mean. ...
2
votes
1
answer
563
views
kNN for non-ordinal variables
kNN is a distance-based method, so it requires the input to be in numerical form.
I was wondering if it is possible to use kNN imputer for non-ordinal categorical variables (like color).
Since the ...
2
votes
2
answers
216
views
Categorical Variable Embedding
I have a categorical variable in my labeled dataset. I trained one-hot encoded version of it in another neural network having embedding layer with a larger labeled dataset. I have obtained the weights ...
2
votes
1
answer
303
views
Two questions about one-hot encoding: drop first? and features with thousands of categories [closed]
I have two questions about one-hot feature encoding:
(1) Is it considered a "best practice" to drop the first (or at least one) one-hot encoded feature when one-hot encoding, like you would ...
2
votes
2
answers
617
views
Is it acceptable to use label encoding for nominal categorical data when one hot encoding would create too many features?
I'm working on a short data science project to compare the accuracy of different classification methods. The groups decided to use and compare Random Forest, Naive Bayes and SVM.
The dataset we are ...
2
votes
1
answer
443
views
Categories with the same mean in target encoding
While doing target encoding it can happen that two categories have the same target mean.
This is bad because there will be no difference in the new feature in it and we will lose some information.
...
2
votes
1
answer
23
views
Memory efficient encoding logic for group categories
I have a huge dataset with categorical data. It is comprised of alerts having multiple properties. Each alert belongs to a group, and some even belong to multiple groups. It looks somewhat like this:
...
2
votes
1
answer
183
views
Different encoders applied to a dataset
I have a dataset which have both categorical features with high cardinality (>8000) and low cardinality (4 or 5).
Would that be ok to encode the high cardinality ones with one encoder (target encoder,...
2
votes
0
answers
197
views
Does it make sense to use target encoding together with tree-based models?
I'm working on a regression problem with a few high-cardinality categorical features (Forecasting different items with a single model).
Someone suggested to use target-encoding (mean/median of the ...
2
votes
2
answers
168
views
Decision Trees and Categorical Feature Labelling
I am working on a decision tree model and trying to decide how best to handle categorical features. The features in my dataset are generally high in cardinality and I have found that ordinal labeling ...
2
votes
1
answer
289
views
Using the curse of dimensionality for encoding non-ordered (nominal) categorical variables of high cardinality
When the dimension is high, all data are approximately at the same distance away from each other. This makes distance-based methods such as k-nearest neighbors less useful if the data are more or less ...
2
votes
1
answer
426
views
Cat2Vec implementation X = categorical and y = categorical
I am trying to convert categorical values (zipcodes) with Cat2Vec into a matrix which can be used as an input shape for categorical prediction of a target with binary values.
After reading several ...
2
votes
1
answer
353
views
One-hot & interaction one-hot on multiple categorical
I was wondering if there is any value to creating combined features out of multiple categorical variables when the individual categorical variables are already one-hot encoded?
Simple example: there ...
2
votes
2
answers
2k
views
Why is count encoding effective in improving accuracy? [duplicate]
Can someone please explain why/how Count encoding of categorical features improve accuracy in classification when compared to simply label encoding them ?
I found one explanation in kaggle " ...
2
votes
1
answer
80
views
What to do if a specific label of a category appears only a few times?
Let's say I am trying to predict whether a car will be auctioned or not (not what I'm actually trying to do, but it represents it pretty well) using tabular data. I have the year the car was made, its ...
2
votes
0
answers
327
views
Multi-valued categorical features in LIME
I am working with the LIME implementation by Marco Ribeiro (https://github.com/marcotcr/lime). Specifically, I am utilizing the LimeTabularExplainer as I have a mixture of numerical and categorical ...
1
vote
2
answers
288
views
Encoding features with big amount of classes
Is it worth to encode features with big amount of classes ( such as 60 )? Or should I leave it as it is ?
1
vote
1
answer
58
views
N-ary decision tree with categorical features
I want to build an n-ary decision tree with categorical features.
I am using ordinary ID3 algorithm to build a tree.
Lets take the next dataset as a training dataset for building a decision tree:
...
1
vote
1
answer
254
views
Encoding for Linear Regression
I have a CSV file with salary information and other columns.
I am trying to transform some of these columns into proper values, for a ...
1
vote
2
answers
4k
views
Encoding categorical data with pre-determined dictionary
in case feature encoding, if I'd like to encode my values based on my pre-determined dictionary, how do I do that?
For instance, say, I've values as ...
1
vote
1
answer
1k
views
sklearn serialize label encoder for multiple categorical columns
I have a model with several categorical features that need to be converted to numeric format. I am using a combination of LabelEncoder and OneHotEncoder to achieve this.
Once in production, I need to ...
1
vote
1
answer
120
views
Can we optimize regression problems that have categorical variables by encoding them if on the other hand we are inserting multicollinearity? [duplicate]
Can we optimize regression problems that have categorical variables by encoding them if, on the other hand, we are inserting multicollinearity?
1
vote
2
answers
616
views
Can decision trees handle Nominal Categorical variables?
I have read that decision trees can handle categorical columns without encoding them.
However, as decision trees make splits on the data, how does it handle Nominal Categorical variables?
Surely a ...
1
vote
1
answer
28
views
How to prevent my model from mistaking categorical feature for ordinal feature
I have tabular data where each group of 100 rows represents a deployment of a specific geometry that has certain features measured. For example, I have 10000 deployments stored in a column called &...
1
vote
1
answer
92
views
If I use Weight of Evidence to transform categorical variables, do I still need to inform their indexes to Catboost
I'm using Weight of Evidence (WOE) to encode my categorical features. Do I still need to inform Catboost that they are categorical features by using cat_features parameter?
1
vote
1
answer
250
views
Categorical feature encoding
I am making a classification model. I have categorical and continuous data.
The categorical columns include columns with 2 classes such as sex (male, female), and multi-class columns such as location.
...
1
vote
2
answers
777
views
Different number of features in train vs test when using Label Encoding
This is not a duplicate of Different number of features in train vs test
There are some categorical columns in my data, and the cardinality for each of them is large, so I chose to use LabelEncoding ...
1
vote
1
answer
1k
views
What is sum encoding?
I've heard sum encoding mentioned as a method of encoding categorical variables, but I haven't been able to find a clear explanation of what it actually is.
I found the following explanation on ...
1
vote
1
answer
34
views
Which ML classifier is appropriate for me if all of my features are categorical?
My dataset contains four features. All of the features are categorical. There are 150 categories in the value of 1st and 2nd features. There are 8 categories in the value of 3rd and 4th feature. I ...
1
vote
2
answers
5k
views
what should i do if my target variable is categorical when using decision tree? (many categorical variables)
all,
i'm trying to classify a set of features to belong to a particular company (my dependent variable). my independent variables are a mixture of continuous and categorical features.
my data-set ...
1
vote
1
answer
128
views
Revisit - Encoding before vs after train test split?
Background: Like a good data scientist, I planned to fit my encoder on my training set and use it to transform my test set. However, when I tried to transform my test set, the encoder threw an error....
1
vote
0
answers
42
views
Intuition behind catboost encoding techniques
Can anyone please help me in understanding the effect of various bucketing techniques used in CatBoost Algorithm for categorical features? Like there is border, buckets, binarized target mean, counter ...
1
vote
0
answers
216
views
Encode each comma separated value in Pandas
I have a dataset
...
1
vote
0
answers
120
views
Handling date and time fields for classification task
I'm working on a classification task(The dataset is 400,000 rows and 30 columns) and one of my features was date-time. I've extracted the month, day of the week, and hour from the dataset (year is a ...
1
vote
1
answer
128
views
Categorical encoded variables in scikit-learn diabetes dataset [closed]
When using sklearn.datasets import load_diabetes, the sex variable which is categorical, is scaled to continuous values. Is it even legal to scale such variables?
1
vote
1
answer
978
views
Should one-hot encoded categorical features needs to be scaled when used along with text feature while deriving semantic similarity?
My aim is to derive textual similarity using multiple features. Some of the features are textual for which I am using (Tfhub 2.0) Universal Sentence encoder. There are other categorical features which ...
1
vote
0
answers
324
views
Implementing Scikit Learn's FeatureHasher for High Cardinality Categorical Data
Background: I am working on a binary classification of health insurance claims. The data I am working with has approximately 1 million rows and a mix of numeric features and categorical features (all ...
1
vote
1
answer
200
views
How to do target encoding when data has repeated rows?
How can I do encoding for a category when data has repeated rows? Can I do target encoding? Or Can I utilize another encoding?
I want to figure out how to include a categorical variable in a model to ...
1
vote
1
answer
51
views
LabelEncoder with a Multi-Layer Perceptron?
So we're working on a machine learning project at work and it's the first time I'm working with an actual team on this. I got pretty good results with a model that uses the following SKLearn pipeline:
...
1
vote
2
answers
305
views
Dummy encoding the categorical variables using the changed version of OneHotEncoder [duplicate]
This is my code, I was trying to dummy encode the first column of X using OneHotEncoder but it was showing error and the documentation page of OneHotEncoder says that it has been changed and I wasn't ...