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.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

Coding data for regression on unordered pairs

I want to fit a regression on "unordered paired data", but I'm uncertain on how to code it. What I mean by paired data is the following: The model looks like this: $$o_i \sim \text{Binom}(1,p)\\ f(...
0
votes
0answers
20 views

Categorical Variables Encoding of Sets

I'm facing a problem in which I need to encode a categorical variable, which can take several values at the same time (and is basically a set), as input for a classifier. For instance, assuming the ...
0
votes
0answers
19 views

design a contrast matrix (R) for comparing each levels with the rest

Based on the discussion in this post I wanted to implement a contrast matrix where I am able to compare each level of a factor variable with the average of all others. If I have 3 levels (I am ...
0
votes
0answers
14 views

Mediation regression

I am trying to find the relationship between audit partner rotation on audit quality mediated by audit fees. My third hypothesis which tests the mediation is this: DA = b0 +b1*PROT + b2*LNAUFEE. DA is ...
2
votes
0answers
14 views

How can I create interactions between categorical variables with Sklearn?

How can I create interactions between categorical variables with Sklearn? I have two predictors that are the hour of the day and the day of the week (DOW). The model is a Binary Logistic Regression ...
0
votes
0answers
8 views

How to use target encoding : expanding mean on the test set

The expanding mean is a way to prevent overfitting when performing target encoding. But what I do not understand is how to use ...
2
votes
0answers
21 views

Categorical variables sklearn random forest

I'm a bit confused with the use of Random Forest in Sklearn in case we have categorical variables. I've read this article stating that one hot encoding affects performance negatively when using ...
0
votes
0answers
13 views

Does inclusion of categorical dummy variables impact OLS prediction?

Say I am trying to predict city price levels of apartments and my dataset contains a variable coded as 'region' (which is a larger geographical variable than city) for 4 levels: region N, region S, ...
0
votes
1answer
29 views

Can SAS Least Squares Means estimation algorithm be translated for a design matrix in Reference coding?

My question is whether it’s possible to compute lsmeans defined in this SAS algorithm if the design matrix is not in GLM form. In particular, in R, if one feeds that design to model.matrix(), then ...
0
votes
0answers
9 views

Conditional independence of attributes in NB algorithm and independence of levels in Target Encoding

This is not an actual question but I really need what you are thinking about it. I have an advisor, not pretty much knowledgeable about Machine Learning/Deep Learning and Statistics. While we were ...
1
vote
0answers
43 views

Dummy variables and interactions

To avoid perfect multicollinearity, a common practice is to drop one dummy variable when encoding categorical variables in a linear regression model (avoiding dummy variable trap). I am using this ...
1
vote
2answers
21 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
1answer
50 views

Does it make sense to use ANOVA with one-hot-encoded data?

I have a data set with different feature types (numerical and categorical). I applied one-hot-encoding to the categorical features and then used ANOVA to find most relevant features. 6 of 66 features ...
0
votes
1answer
20 views

How to handle potential ambiguity when one-hot encoding?

Let's say I have two categorical features: Movie, Director. I one-hot encode both the Movie and Director features for use in a linear regression model. The problem is that two or more movies may be ...
0
votes
0answers
10 views

Including Multiple Sets of Dummy Variables in a Regression---interpretation of parameters?

I am currently setting up a multivariate Logit Regression, and I am curious about including multiple different multi-categorical dummy coefficients in a regression. So for example, let's say I have ...
0
votes
0answers
11 views

How to pass this mock one-hot-encoded data through keras LSTM layer?

As (I think) I understand in Keras, LSTM layers expect input data to have 3-dimensions: (batch_size, timesteps, input_dim). However, I'm really struggling to ...
2
votes
2answers
61 views

If I have five levels of a categorical predictor, is there any way to get coefficients for each level?

I have a categorical predictor with five levels. Every coding scheme I find produces four coefficients. What should I do if I don't have a natural reference level, and would like to see the effect of ...
0
votes
0answers
22 views

How to code a predictor in regression when some values are purposefully unknown

I ran a psychological experiment involving two conditions. An independent variable - made up of numeric values - was present in one condition but not in the other. Accordingly, in one condition the ...
1
vote
0answers
25 views

When do I have to use orthogonal contrasts instead of non-orthogonal ones?

This is the same question as asked here, but of course I think with a different twist. A definition of orthogonal contrasts is given in another (great) answer to a popular question on Cross Validated ...
1
vote
2answers
51 views

Can I use a frequency distribution to encode categorical variables in a neural network?

I would like to use categorical features to train an autoencoder neural network. Typically for categorical features my approach has been to one-hot encode the features to make indicator features. The ...
0
votes
0answers
5 views

How to create linear user embedding from some answers to binary questions?

I have each user U_i answering 10 binary questions out of a pool Q with either answer 1 or 2. I would like to learn an embedding of user profiles based on these answers to predict is answer to other ...
1
vote
1answer
19 views

What happens when you merge dummy variables together?

Suppose I want to regress $X$ on $y$, controlling for categorical $z$ with $100$ different levels. I believe that linear regression is appropriate. Normally I would create dummies $D_i$ for each ...
1
vote
1answer
70 views

weighted one-hot encoding

I am using one-hot encoding to transform my categorical variable. But it's not just a presence-absence situation. Consider the variable as a device that can have with different brands as well as ...
1
vote
0answers
20 views

Main effect omitted as it is time-invariant. Is including the interaction without the main effect an issue?

I am interested in the impact of Unemployment (U) on Gross Domestic Product (GDP). I also want to check if the effect is different for developed countries and developing countries. I am using 10 ...
0
votes
0answers
6 views

Finding and presenting solution for optimized supplier portfolio

I am trying to find the best solution to create a "model" and presentation of the following challenge: I have several products which shall be bought from as few suppliers as possible. For each ...
0
votes
0answers
17 views

Categorical encoding on test set using h2o (R)

I trained a GBM with the following parameters ...
1
vote
1answer
32 views

Can I use the interaction between a dummy variable and the variable it was derived from?

I am trying to make a multiple linear regression model. I have a hypothesis that $x$ is a significant predictor of $y$ but only when $x > 0.5$ ($x$ ranges from -2 to + 2). Is it acceptable to ...
0
votes
0answers
9 views

How many groups of dummy coded variables can be included within one step of Hierarchical Regression?

I am conducting a hierarchical multiple regression analysis. I have several predictor variables which are nominal and ordinal. From what I understand, these need to be coded into dummy variables (each ...
1
vote
1answer
55 views

Alternatives to using dummy variables?

I am working on this dataset: https://www.kaggle.com/russellyates88/suicide-rates-overview-1985-to-2016, and it has a lot of categorical variables, while I am more used to work with the continuous ...
1
vote
0answers
17 views

Categorical variable and Logistic regression model

I am trying to run a logit model with different types of independent variables like dummy, continuous and categorical variables. But I am facing problems in the categorical variables. Here, my ...
1
vote
0answers
48 views

Can you use multiple reference groups in a single logistic regression?

When performing logistic regression for a binary categorical variable (i.e. 'gender', being Male or Female in this simple ...
0
votes
0answers
9 views

Appropriate Encoding for Stock Technical Indicators ? RSI

happy new year and i am new to machine learning + python.. so recently i am doing a project on my own to use machine learning models on technical indicators.. I have my technical indicators data ...
0
votes
0answers
14 views

Contrast coding DV in multinomial regression

In a multinomial logistic regression (for example, with 3 levels of a categorical DV), my understanding is that the DV is essentially dummy-coded, with coefficients corresponding to differences ...
1
vote
0answers
15 views

Interpretation of categorical variable coefficients in Linear Regression using sklearn's OneHotEncoder

I'm getting a little confused: when it comes to explaining the interpretation of coefficients of dummy variables in ML, all the sources say that one category is the reference level (i.e. 0) while the ...
0
votes
1answer
12 views

Dichotomous independent variables and interpretation of regression output

I am running a regression on stata concerning the association of smoking intervention types upon participant age of first use. The dependent (age) is a discrete variable by age in years, while the ...
0
votes
1answer
17 views

What do you call a machine learning category encoder that involves counts?

At work I often have a variable encoding where you count the number of each category with respect to a key. (Which makes sense for the domain I am in) Does this process have a machine learning or ...
0
votes
0answers
15 views

Using the autohotencoder in PySpark for a linear regression but no reference category

I created dummy variables using the autohotencoder and as I have learned dummy variables you also need to have a reference category. However I have 7 dummy variables for the weekdays for example, so I ...
0
votes
1answer
37 views

Categorical encoding after discretization

When a variable is discretized it is converted to a categorical variable. This new variable should be encoded back to numeric using label encoding or one hot encoding. I mean, sklearn by default (...
2
votes
2answers
42 views

Rain overflow modeling: Categorical variables or separated models?

I'm working on a project where I have to predict rain overflow due to rain for 5 sewer locations. I have a file which tells me if there is a rain overflow (=1) at a given date for a given sewer or no (...
0
votes
1answer
50 views

Feature Selection Before or after Encoding?

Should I apply feature Scaling and Selection before or after the One Hot Encoding/Label Encoding? Please Correct me if I'm Wrong- Deal with Outliers Impute ...
3
votes
1answer
30 views

Do we use different number of dummy variables for Classical and Bayesian stats?

Let's say we are building a regression model with one nominal predictor, which has three levels, let's say red, blue, and yellow. I remember being taught that when we build the model, we use j - 1 ...
1
vote
0answers
11 views

Multiple interaction terms for dummy variables?

IV: State (NJ, HI, CA, FL) (reference =CA) Moderator: # of hours exercising DV: BMI In this case, the IV is categorical and I have 3 dummy variables. As such, I created 3 interaction terms. In using ...
0
votes
0answers
22 views

Why not all contrasts showing up? [duplicate]

I have a categorical variable with 3 levels: low, mid, and high. I want to do all-pair comparisons with the following contrasts: ...
0
votes
1answer
30 views

What to do with statistically insignificant dummy/categorical variables? [duplicate]

From the research I've done the common answer is that you can not remove insignificant dummy variables from a regression. I'm having a hard time finding academic papers or books that back up this ...
1
vote
0answers
17 views

Testing for parallel trends in panel data/diff-in-diff with only 4 time periods

I am trying to test for common trends on Stata using coefplot, with 4 dummies for each time period (where they equal 1 at time t and if the individual is in the treatment group). However, clearly ...
0
votes
1answer
36 views

Need help understanding logistic regression output with seemingly contradictory results after swapping reference group

Some background, each of these predictors are 0, 1 one-hot-encoded categories that represent items in a basket (think e-commerce). Each observation can have multiple 1s. For instance, a single ...
0
votes
1answer
21 views

In a Dataset with many categorical columns what should be preferred -One Hot encoding or Label encoding when doing regression?

Suppose my Dataset for automobiles has a feature 'Number of cylinders' with labels 'One','Two'..(Strings) as categories,what should be preferred label encoding or One hot encoder?
0
votes
1answer
23 views

Does Dummy creation add multiple features to Dataset or are Dummy variables treated as multiple columns, same feature?

As dummy creation increases our number of columns, as compared to label encoding, how are these treated in our sample data. When using them in our linear regression models, how will they affect ...
0
votes
1answer
19 views

Compact notation for one-hot indicator vectors?

Many machine learning approaches use one-hot vectors to represent categorical data. This is sometimes called using indicator features, indicator vectors, regular categorical encoding, dummy coding, or ...
1
vote
0answers
20 views

Interaction term btw. binary and continuous variable - dropping the intercept?

I run a linear regression with many dummy variables (in total 10). Thus to avoid the dummy variable trap, I dropped the intercept and included all dummy variables. Now I'd like to have a look at the <...

1 2 3 4 5 9