Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [categorical-encoding]

Representing categorical variables as sets of numerical variables. Necessary in many types of analysis for them to process categorical data. A common example is using a categorical predictor in regression/ANOVA via dummy coding, effect coding, Helmert coding, user-defined contrasts, etc.

0
votes
3answers
42 views

Multiple regression with dummy variables and interaction term

We have done a multiple regression analysis to see how gender and experience affect salary. We used a dummy variable for gender and then we also added the interaction variable (female work experience)....
0
votes
1answer
10 views

Differences between Wald Statistics and P-values obtained with Dummy Coding vs. Direct Coding in Cox Models

Using the larynx dataset (source: Survival Analysis Techniques for Censored and Truncated Data) to illustrate, supposing you want to estimates the hazard rates of event for stages 2 and stages 3 ...
0
votes
0answers
17 views

How to code a categorical variable for logistic regression with overlap in the categories/subgroups?

Suppose I have a categorical variable consisting of four levels: a, b, c, and d. When these levels are mutual exclusive, I would use dummy coding - so three dummies with for example level a as ...
0
votes
1answer
24 views

One-hot-encoding gives untractable amount of classes

I'm performing regression on the price of bycicles based on their brand, model and submodel. These features are hierarchical: one model belongs only to one brand but one brand can have many models. ...
0
votes
1answer
31 views

Question about making prediction with only two variables

I have a data set with only two variables, student id and book id. I have train and test sets and I will make prediction about what book student will get next time. Should I attach dummy variables to ...
1
vote
1answer
29 views

(Low cardinality) categorical features handling in gradient boosting libraries

In some popular gradient boosting libraries (lgb, catboost), they all seems like can handle categorical inputs by just specifying the column names of the categorical features, and pass it into a ...
0
votes
0answers
7 views

Cross Level Interactions using HLM7 [closed]

I am running a Bernoulli model using HLM7. I am interested in looking at a cross level interaction effect for 2 dummy variables, but am having difficulties with the software. I was able to add the ...
0
votes
0answers
26 views

Assess impact on results of participants recruited via additional outreach efforts

I am currently working on a project that evaluates certain study recruitment strategies in regards of increasing participation among different subgroups. One of those strategies is reminder letters. ...
1
vote
4answers
217 views

Regression with Lots of Categorical Variables

I'm facing a regression task with many categorical and few numeric features. I encoded them into dummies and removed the first dummy column for each feature. I am not getting very good R2 at all. I ...
0
votes
1answer
27 views

How do I evaluate/validate my encoding technique?

I have log data and I encode the data for clustering purpose. For example, I have one data column and I represent this unique data in numerical values or binary to be as one column as below. Example ...
0
votes
0answers
10 views

Does it make sense to apply recursive feature elimination on one-hot encoded features?

Does it make sense to apply recursive feature elimination on a feature set pre-processed with One-Hot Encoding? This is my code for feature selection: ...
1
vote
1answer
14 views

How is One-Hot Encoding interpreted by an Algorithm?

I'm new to machine learning, and just learned about the use of one-hot encoding as a method of passing a categorical variable as an input into a machine learning algorithm. As I understand it, one of ...
0
votes
0answers
8 views

Censored Dummy Regressor

I have a dataset that contains factors corresponding income ranges of sampled persons, like people with factor 1 earn between 10,000 to 20,000, 2 between 20,000 to 30,000 . I could just make dummies ...
0
votes
0answers
7 views

How to handle different input sizes of an NN when One-Hot-Encoding a categorical input?

let's assume an input dataset that is a mix of categorical values and real values. When preprocessing this data into an appropriate NN input, OHE is recommended because it doesn't assume any order of ...
0
votes
1answer
27 views

How to handle and test categorical dummy variables when interested only in certain levels?

I want to build a multiple linear regression model. I want to test the effect of a nominal variable with 10+ levels, but I am interested in testing only the effect of 2 of them. 1st Question: How ...
1
vote
1answer
43 views

changing the coding system from helmert coding to difference coding changes regression results?

EDIT: I think I have mistaken the names of the coding systems, so I changed it (in bold). The content has not changed at all, though, so I would still appreciate any answer. END EDIT I'm running ...
0
votes
0answers
23 views

How to encode text and categorical variables together?

I have two groups of texts that are very similar (e.g. reviews written on fridays and reviews written on mondays), and I want to build a LSTM that can classify them into positive and negative reviews. ...
1
vote
1answer
52 views

How to interpret interaction dummies of multiple categories and main effect

I have a panel data crosscountry regression with following structure ($y$ as a drug addiction rate of the country, $x$ as number of homeless of the country and $m$ as HIV infection rate of the country)...
-1
votes
0answers
21 views

Scaling after one-hot-encoding/dummy-encoding

I have a few categorical features, along with numeric features in different scales. I'm doing dummy-encoding for the categorical features (not sure whats the different between one-hot and get_dummy) - ...
2
votes
3answers
78 views

Can a dummy variable take on more than 2 values?

I am doing a research on foreign direct investment in the EU countries. I came across an article in which the authors assign 4 values to a dummy variable, to be more specific, they assign the value 0 ...
0
votes
0answers
20 views

Encoding variable number of categorical features

I have a dataset listing the software installed for each user. This dataset shall be used (in conjuction with other user datasets) to classify the user into 4 (imbalanced) categories. There are over ...
0
votes
1answer
78 views

How can I one-hot encode a variable that has only 2 levels? [closed]

I'm trying to do OHC in R to convert categorical into numerical data. However R's caret package requires one to use factors with greater than 2 levels. Any idea how to go around this? I've searched ...
0
votes
1answer
19 views

Is it okay to combine dummy coding and sequence coding?

I have a model with two categorical variables. Each one has three levels. Iv1 has a natural reference category so I would like to use dummy coding, and compare level 2 to level 1, and level 3 to level ...
0
votes
1answer
26 views

Do dummy variables need scaling in machine learning models?

I have a data set with continuous variable and dummy variable (1/0). When using models such as neural, SVM, linear, etc, I was recommended to put the input variables into similar scales, such as mean=...
1
vote
1answer
28 views

ICD10 (categorical) encoding

I am trying to figure out how best to encode ICD10 codes for input into a machine learning model. It isn't ordinal by any means, however, there is a sort of logic you can apply to just the labels ...
1
vote
1answer
36 views

Is there a collinearity issue when using: x, dummy indicating extreme negative value of x and their interaction?

I was wondering whether I can build my baseline model using the following variables without incurring in any multicollinearity issue: $X_1$= Net capital flows over GDP (which may be positive and ...
0
votes
1answer
30 views

SEM setup question: Dummy coding with interaction term

I have an SEM that fits well according to several metrics and returns meaningful results. However, I'm not sure if the structure is valid. I have 3 between subjects conditions (2 treatments and one ...
1
vote
1answer
272 views

Cross Entropy Loss for One Hot Encoding

CE-loss sums up the loss over all output nodes $\sum_i[ - target_i*\log(output_i) ]$. The derivative of CE-loss is: $- \frac{target_i}{output_i}$. Since for a target=0 the loss and derivative of ...
0
votes
0answers
89 views

dummy vs one-hot encoding - ML for prediction

I understand there is a lack of consensus in the difference (if any) between one-hot (k variables) and dummy (k - 1 variables) encoding from a k-level factor. The caret package seems to auto-encode ...
0
votes
1answer
27 views

Dummy Variable, Reference Group

My job is to create a dummy variable so that those who voted for the Labour Party are compared to a single reference group that includes all other voters. 1 = Conservative, 2 = Labour, 3 = Liberal ...
-1
votes
0answers
17 views

What is the the cost of combining categorical variables?

I have 2 categorical variables e.g. state and city. Missing values progress as such city > state. As opposed to throwing out all observations with missing values for city or throwing out city all ...
0
votes
0answers
27 views

When coding categorical predictors as dummy variables for a Naive Bayes classifier, should the reference levels be left out?

Perhaps another way of putting the question would be: "Do Naive Bayes classifiers have intercept terms?" My statistical training tells me that a predictor with $k$ categories should be coded as $k-1$ ...
3
votes
1answer
282 views

Can you have interaction terms for both “sides” of a dummy variable in a single regression?

I'm really not sure how to phrase my question properly, so I apologize if this has been answered elsewhere. Let's say I'm interested in using a regression to predict wage using sex and an interaction ...
2
votes
1answer
30 views

WLS vs Dummy variable coding for heteroscedasticity

I am a beginner level stat learner (with graduate training in Applied Math) I have just read a sage book which states the following: "Dummy variables help address the issue of heteroscedasticity in ...
1
vote
0answers
47 views

Dropping some levels of dummy-coded categorical variable in a linear regression due to too few observations

I want to run a linear regression in SPSS N = 1400 Outcome variable = rating from 0 to 800 (participants saw or heard a Mandarin speaker and had to rate how pleasant the speaker was feeling) ...
1
vote
1answer
25 views

Separate Models vs Flags in the same model

I have customer data from 2 brands. The data structure are the same, but I expected the customer behaviour to be different in different brand. So I could train 2 models, 1 for each brand, or I could ...
0
votes
1answer
31 views

Interpretation of quantitative variable in regressions with and without dummy variables

I was provided with results from two regressions: (1) log(annual_salary) = B1*yrs_experience + B2*PhD + B3*Masters + B4*Bachelors + e (2) log(annual_salary) = B1*yrs_experience + e where '...
2
votes
3answers
57 views

multiple regression with two dummy variables - calculating difference between groups

I am running a multiple regression: Visits to a tourist attraction = 𝛽0 + 𝛽1ticket price + 𝛽2income + 𝛽3 age + 𝛽4female + 𝛽5local (local vs foreign visitors) I wonder how to 1) calculate the ...
0
votes
0answers
10 views

Glmer - Changing refrence level changes data

I am currently fitting a glmer model to my data. Formula: (y ~ x1 * x2 * x3 + (1 | RandomEffect1) + (1 | RandomEffect2)) x1, <...
4
votes
1answer
72 views

VIF Drops Significantly When I Delete Some Dummy Variables

Is my model valid even with the high VIF? Does it matter which dummy variable I drop as the reference point? I have a a category variable (Fruit) that I converted ...
0
votes
0answers
15 views

One Hot Encoding: split feature into as many categories as possible, or lump data into smaller no of bins (including multiple split categories)?

I am working on a Machine Learning problem on a bike-share system database to predict the total number of bikes rented (per hour) based on other data. I used one-hot-encoding to split up the ...
0
votes
0answers
19 views

Dummy Variables in Neural Networks and Random Forests

In logistic regression, dummy variables are included in the model with k-1 categories. However, I am not sure how to deal with dummy variables using NN, RandomForests, DecisionTrees, and other ...
1
vote
2answers
67 views

Dropped 2 Categories in Dummy Variables (Logistic Regression)

I understand that when modeling, dummy variables should be k-1 and the dropped category should be the baseline. However, I do not know how to interpret if after feature selection 2 more categories of ...
1
vote
1answer
50 views

Can a covariance matrix be recalculated for dummy variables?

Say I have the following sample from a continuous variable $X$ and a categorical (dichotomous) variable $Y$: X Y 0.5 1 2.3 2 2.2 2 1.8 1 Moreover, the covariance matrix between $X$ and $Y$ is also ...
1
vote
1answer
63 views

Reasons not to one-hot-encode categorical features

I overheard a colleague discussing her strategy for using categorical features the other day, and she mentioned that instead of one-hot-encoding, she does something like this: ...
1
vote
2answers
86 views

Non-negative matrix factorization (NMF) on mixed data using 1-hot encoding

From a standpoint of interpretation, can I use NMF on one-hot encoded categorical data for dimension reduction? I have mixed data and was thinking about one-hot encoding the categorical features and ...
0
votes
0answers
26 views

How to test for a reduction in gendered language? What would the outcome variable be?

Say I’m looking at dating website profiles. I note 20 adjective that are much more likely to be used on females’ profiles than males’ profiles. I note another 20 adjective that are much more likely to ...
1
vote
2answers
111 views

Convert categorical variable to numeric values or dummies for k-means clustering? [closed]

I am using K-Means clustering algorithm on a dataset. One variale has 6 categories and I want to know how to deal with this. I am thinking of two approaches: Converting the values to 1,2,3,4,5,6 ...
1
vote
1answer
25 views

Combining successive and treatment contrasts in lmer

I am running a lmer mixed effects model with three fixed effects parameters, each having multiple levels: predic1: HH LR RR LD (4 levels) predic3: L1 L2 L3 L4 (4 levels) predic2: A B C D E F (5 ...
0
votes
1answer
37 views

Categorical Variables in Random Forests

I am aware that categorical variables should be one hot encoded before modeling with random Forests. But I am not entirely sure why. Lets say we have a predictor categorical variable with 7 levels. ...