New answers tagged

0

You may want to tokenize the strings, e.g., “Mustermann GmbH” tokenizes into "Mustermann" and "GmbH". Allow for spaces and commas certainly, perhaps also hyphens and other punctuation. You may want to look into Natural Language Processing (NLP) if you're classifying text, but whatever method you choose should have better luck sniffing out business vs. non-...


1

LabelEncoder is meant for the labels (target, dependent variable), not for the features. OrdinalEncoder can be used for features, and so can take a 2d array rather than the 1d array LabelEncoder requires, and so you can use a single transformer for all your categorical columns. (You can use a ColumnTransformer to select those categorical columns, if you ...


1

PCA is not recommended for categorical features. There are equivalent algorithms for categorical features like CATPCA and MCA.


2

Here is nice implementation of mixed type data in R- https://dpmartin42.github.io/posts/r/cluster-mixed-types This question right here- K-Means clustering for mixed numeric and categorical data and a Discussion Thread of Kaggle- https://www.kaggle.com/general/19741 There are ways, to either map your categorical data to numeric type and then you can go ...


1

You will need some way of converting categorical data to numerical, or numerical to categorical. One way to do this (convert categorical to numerical) is with one-hot encoding, where you look at the number of categories you have and make a vector of that size. Then, you can map each datapoint to a vector with 0 everywhere except for the location for the ...


0

I hope this is not a late answer but actually you can use category_encoders library, it follows sklearn's style. Example: import category_encoders as ce #I'll pretend that you've already split your data into train/test #your categorical features cat_features = ['cat_feature1', 'cat_feature2'] #count encoder count_encoder = ce.CountEncoder(cols=...


0

If the categorical variable is binary(like e.g sex) you try Point biserial correlation coefficient. Or recode levels of var(woman->1, man->0) and use pearson correlation. Recoding it's a risky way because of you indicate order(woman>man). You should be aware of that. Also $\chi^{2}$ test is used to determine whether an association (or relationship) between ...


1

If you don't encode numerical categories with dummy variables, some models will end up being trained to use an ordering of numbers (e.g. 1 < 2 < 3 < 4 < 5 < ...) in their predictions. Whether or not this is desirable or useful depends on the context, and in particular on the meaning of the numerical categories and the model and implementation ...


Top 50 recent answers are included