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
1 answer
1k views

How many dummy variables should I use?

I have data of four different regions that will be made into dummies. The problem is one of the regions only has one observation. The others have 30-50 observations. Is it ok to do a multiple ...
Yonla's user avatar
  • 3
0 votes
0 answers
57 views

Linear regression with a factor variable of 4 categories but less than 3 dummies

I need some help with the following: I have a regression problem of income and degree type. Degree is a factor with 4 levels: high school diploma, bachelor's degree, master's and phd. In order to run ...
thenac's user avatar
  • 341
1 vote
1 answer
566 views

How to handle the dummy variables with overlapping categories?

Background of The Question Let's say, I have four categories (A, B, C, D). Considering one (D) as a reference variable, there will be three categories on which I have to work. But the problem is one ...
Md Sabbir Ahmed's user avatar
1 vote
1 answer
75 views

What is the correct way to test multiple dummies?

I'm discussing a topic with classmates and the textbook does not address our concerns. In the following model: $$wage = \beta_0 + \beta_1 female + \beta_2 educ + \beta_3 (female \times educ) + u$$ it ...
chatGPT's user avatar
  • 127
0 votes
1 answer
57 views

Further breakdown of a dummy variable for regression analysis

I would like to measure the athletic performance based on his smoking status. And in addition, I want to evaluate the difference between cigarettes and cigars. Smoker vs. non-smoker: S = 1 , if ...
Olaf_SQL's user avatar
1 vote
1 answer
850 views

Categorical covariates in Cox model in R

When there are multiple levels in a variable (ex. 1,2,3,4), should I use as.factor() to transform it to a factor when I fit a cox model in R? When there are only two levels (ex. 1 for male and 2 for ...
user10386405's user avatar
1 vote
0 answers
122 views

Doubt on regression analysis interpretation

I have a dataset made of more than 10K observations. For each of them I know the value of a continuous variable (C1), and the value of three nominal variables: N1, which can take three different ...
Nuthatch92's user avatar
1 vote
0 answers
279 views

LSTM: Best way to handle categories, in practice

There is an issue emerging in the practical use of Long-Short-Term-Memory (LSTM) Deep Neural Nets (DNN) with my use case. In typical machine learning scenarios one encounters in benchmark datasets, or ...
Chris's user avatar
  • 336
1 vote
0 answers
24 views

Does the N-dimensional hypervolume refer to the N attributes we have in the training sets?

If we have $N$ features in the feature set that is being used to train a machine learning model, does the $N$ here cause the data points to be in hyperspace provided that $N > 3$? I'm assuming that ...
learnerX's user avatar
  • 223
1 vote
0 answers
2k views

Can I use month as a numerical variable (and not as a categorical variable) in linear regression

Let's say my response is $Y$. I know for a fact that $Y$ decreases during winter time, and then starts to increase around spring. So, does it make sense to use month (not as a categorical variable) as ...
Shashank's user avatar
0 votes
1 answer
2k views

How do I interpret the coefficients of the reference group for a linear regression with two dummy variables as regressors in R?

I'm using R to fit the following linear regression models with the popular "mtcars" dataset: ...
caproki's user avatar
  • 129
2 votes
1 answer
605 views

Running ANCOVA with categorical covariates - how to set up dataset?

I am analyzing a dataset in which 80 participants rated 4 products (product A, product B, product C, product D) from -3 to 3 depending on how much they liked the product. Each participant provided ...
PsychStudent3's user avatar
2 votes
1 answer
495 views

Handling intentionally missing data with tree-based methods

I am using a tree-based method (specifically, random forest) to model the quality of sunsets based on weather measurements. One feature available is the height of the clouds. When there are no clouds ...
Matt Stevans's user avatar
1 vote
0 answers
366 views

Panel Data Regression in R with Dummy Variables [closed]

I am currently working on my thesis and thereby analyzing the effects of the increase of COVID-19 cases on the main stock indices of the G7 countries. For this purpose, I have divided the whole period ...
Rachel's user avatar
  • 11
4 votes
1 answer
72 views

Why do we not use continuously defined losses in NLP?

I understand that various problems in optimization in NLP which do not exist on continuous tasks such as vision, arise in NLP because we do not have continuous data to predict, but one-hot vectors ...
infobox's user avatar
  • 43
0 votes
0 answers
354 views

Predictors that are integers and factor types in a linear model

I am running a hierarchical linear regression. My predictors consist of both continuous and categorical variables. R treats the continuous variables as integers, and I have converted the categorical ...
anelson's user avatar
  • 53
0 votes
0 answers
20 views

Why label encoding for categorical features should not be used for deep learning/neural network? [duplicate]

Many online posts(here and here) say label encoding would make NN/DL models think there is an ordering among categories, so it should not be used for categorical encoding for NN/DL models. But wouldn'...
etang's user avatar
  • 977
2 votes
1 answer
1k views

Is there ever a reason to one-hot encode ordinal data?

This is a general question, but I will provide a real scenario that occurred which prompted me to ask this question: I took over a project and noticed that one of the variables "conflict event ...
rocksNwaves's user avatar
2 votes
1 answer
1k views

The gradient of neural networks w.r.t one-hot encoded inputs

One-hot encoding as raw inputs for deep learning models can find its applications in many domains, such as bioinformatics, NLP, chemistry and so on. Suppose we trained a neural network $f(x)$ with $x$ ...
doubllle's user avatar
  • 1,828
0 votes
0 answers
205 views

Target encoding categorical variables when population means are known

Target encoding (aka mean or categorical encoding) converts a categorical independent variable to a continuous response for use in predictive modelling. In its most basic form, it does this by ...
Terry B's user avatar
  • 55
1 vote
1 answer
69 views

Linear regression with 2 different categorical variables

I'm confused how the data is stored for 2 categorical variables, consider the example where we are testing the response of y with whether someone says yes or no, with simple formula $y = \alpha + B_{1}...
Wallace's user avatar
  • 207
1 vote
0 answers
34 views

Represent Integer Categorical feature as both Numeric and Categorical

I'm dealing with tabular datasets where it's really hard to tell if the integer column is Numeric or Categorical. My main consideration is the accuracy of the model that I am building (no deep ...
user2991421's user avatar
2 votes
1 answer
194 views

Intercept of negative binomial Regression with weighted effect coded variables does not equal sample mean

I am facing a really puzzling issue. I am analysing data of employees' absentism because of illness during four months with a negative binomial GLMM with the employees' department as a random effect. ...
Frith Nanth's user avatar
0 votes
1 answer
46 views

Uneven intervals for a score

I want to create categories to classify some variables into "Good", "Regular" and "Bad" performance. Each variable has its own measure and its own reference value (like a ...
Cristhian 's user avatar
4 votes
1 answer
368 views

R mixed effects modeling - analysis and interpretation

I am trying to use mixed-effects modelling for my data in R. I have two independent variables and both of them have three levels. Is it necessary that I have to code my variables? If so, can I use ...
Christina's user avatar
1 vote
2 answers
2k views

Target Encoder for Logistic regression

I have a data set that has many categorical values, I want to build a linear model using Logistic regression algorithm. One way of handling Categorical variables is ...
deltascience's user avatar
2 votes
1 answer
116 views

How to fit a multiple membership model when the factor is nested?

The accepted answer to this question explains how to fit a mixed effects model where there is multiple membership. I would like to know how to proceed when the multiple membership factor itself is ...
Joe King's user avatar
  • 3,815
0 votes
0 answers
31 views

One hot encode nominal categorical variables for random forest? [duplicate]

I looked for this before but I couldn't find it exactly, so let me know if it's a duplicate. My question is, should categorical variables be one hot encoded to run Random forests? Or just transforming ...
amestrian's user avatar
  • 255
1 vote
0 answers
210 views

Adding categorical features to each pixel of an image for use in CNN model

I am building a model which generates new image from an imput image. I have a training set of input images and desired generated images and I also have some categorical data for each pixel of an image ...
Amuoeba's user avatar
  • 111
0 votes
0 answers
37 views

Logistic Regression with dummy variables? [duplicate]

I am working on a problem where response variable is binary and my features are dummy variables. I observed when I include intercept to model all the dummy variables' p-values are equal to 1. When I ...
CheeseBurger's user avatar
4 votes
1 answer
947 views

Hierarchical Categories as Input Features

I have a regression problem. Two input features describe a category and subcategory. For illustrative explanation, let's consider we speak about city and district. Some more details about the ...
Karel Macek's user avatar
  • 2,816
1 vote
2 answers
415 views

How to identify coefficients for all levels of categorical variables when you have multiple of them

I have an equation like y ~ x1 + x2 + x3 + x4 where the first 3 variables are categorical and the last one is continues. I want to identify the coefficients for all ...
Ragıp Gürlek's user avatar
7 votes
1 answer
191 views

Which categorical variable encoding should I use if I want the model intercept to have the interpretation of the global mean?

In a mixed effects model $$ y_{ij} = \beta_{00} + \beta_{01} x_{1i} + \beta_{02} x_{2i} + \beta_{03} x_{3i} + u_i + \epsilon_{ij}$$ where $x_1, x_2, x_3$ are dummy variables coding the levels of a ...
tomka's user avatar
  • 6,602
1 vote
1 answer
422 views

Is it reasonable to convert factor (only 0/1 involved) into numeric data?

If I have a simple data with only 2 levels of factors: ...
Math Avengers's user avatar
3 votes
1 answer
936 views

What is the impact of a dummy variables to boosted trees?

I am currently reading the book "Random Forests" by Yu. L. Pavlov. Then it came across my mind the question If I were to use ensembled tree, say XGBOOST, do I need to transform each ...
Gerard's user avatar
  • 181
1 vote
0 answers
301 views

One Hot Encode and Logistic Regression [duplicate]

When using Logistic Regression, and the categorical variables are one hot encoded, do we always have to drop a variable to avoid the dummy variable trap? If I recall it correctly, I have seen ...
Kyle's user avatar
  • 31
1 vote
1 answer
948 views

How many observations should a dummy variable encompass?

So I feel like this is a rather stupid question, but I can't find a straightforward explanation on the issue. When constructing a dichotomous dummy variable, how many observations should each category ...
philipp.kn_98's user avatar
4 votes
1 answer
1k views

Up to what number of distinct values should I transform a categorical variable in a dummy variable?

When working with categorical variables, it's common to do some sort of transformation. Usually people apply a one-hot encoding. Putting it simply, we transform a categorical into a dummy variable. ...
trder's user avatar
  • 660
0 votes
1 answer
354 views

How to encode ordinal variables when null value is valid?

Tl;dr how can I encode a feature that has multiple distinct states each with different numbers of parameters. Am I going to have to break this into multiple models? I'm sorry, I'm sure this has been ...
MacKenzie's user avatar
2 votes
1 answer
73 views

Compute standard errors of cell means from regression coefficients

Say I have the following regression model: ...
Parseltongue's user avatar
  • 1,010
0 votes
1 answer
35 views

Logistic Regression, continuous feature is categorical

I'm using logistic regression for a simple binary classification. I have a feature, x, and looks something like this ...
so_many_questions's user avatar
1 vote
1 answer
97 views

Should I include the date variable in addition to a dummy variable for observations after a certain date in multiple regression?

The main variable I'm investigating is a dummy variable that is 1 after a certain date and 0 before, denoting when a certain law passed. When I include date, date is significant and the dummy is not, ...
gus_mac's user avatar
  • 55
2 votes
1 answer
234 views

Ordinal Feature Encoding (Linear or Nonlinear?)

In most ordinal features, it seem that the scaling is linear. E.g. [1, 2, 3, 4] with higher score representing larger effect on the target variables But is it ...
K_inverse's user avatar
  • 185
0 votes
1 answer
275 views

2D convolution with values that encode categorical data

I have got raster images of the spatial distribution of categorical data. For each pixel of the image, I know which single category (A to F) is present in that pixel. Each image belongs to a class ...
toliveira's user avatar
  • 297
0 votes
1 answer
69 views

Is it correct to use categorical inputs in a Neural Network to predict another categorical output?

Let's say we want to predict only whether next day's temperature is going up or down (so two classes as opposed to predicting the actual temperature). Would there be any issues with using another ...
Metrician's user avatar
  • 159
-1 votes
2 answers
556 views

redundant level dummy variable [closed]

In classical statistical regression analysis (e.g. linear regression) one level of the categorical variable is usually not used to create a dummy variable to create a reference (e.g. there is only one ...
cs0815's user avatar
  • 2,235
0 votes
0 answers
211 views

Literature of one-hot encoding performance v.s. others

For categorical classification, I couldn't find literature comparing one-hot encoding v.s. others from either theoretical or empirical point of view. I understand one-hot encoding is probably too ...
Shen-Fu Tsai's user avatar
1 vote
0 answers
51 views

Modeling with Multiple Values per Variable, per Observation

I'm attempting to develop an autoencoder on top of medical claims data that have mutliple values per category because a claim often has multiple lines associated with it. For example, let's say (but ...
bshelt141's user avatar
  • 227
3 votes
0 answers
708 views

Is there a label smoothing version for multi-label classification?

I use label-smoothing for multi-class single label classification as follows. ...
devforfu's user avatar
  • 335
4 votes
1 answer
62 views

How to encode single & combination treatment groups for mixed effects model?

I am preparing a data analysis for a longitudinal study investigating the effects of two treatments (A & B) over time with the following 4 groups: Group 1: Control (Saline) Group 2: Treatment A ...
user294162's user avatar

1
5 6
7
8 9
17