Medium
medium.com โบ aiskunks โบ categorical-data-encoding-techniques-d6296697a40f
Categorical Data Encoding Techniques | by Krishnakanth Naik Jarapala | AI Skunks | Medium
March 27, 2023 - โข This categorical data encoding method transforms the categorical variable into a set of binary variables [0/1].
Downsides of target encoding compared to one hot encoding?
One issue is you're sort of using the data twice: first you use the target to make your new feature ordinal, then you use those same labels to train your learner at the following step. This can increase model variance. Second potential issue is if you're using a tree-based model you're limited to using your new ordinal feature only one time in the tree. If you one-hot encoded you could use one of the resulting features at the top of the tree, and another down the branch. Typically you would use target encoding for a high-cardinality feature if one-hot encoding would explode the feature space to the point that the model would be difficult to manage. If you can afford the added features I would stick to one-hot. Target encoding is a useful technique just be aware of the impact it may be having on the model you're training. More on reddit.com
[D] Why one-hot encoding is a poor fit for random forest classifiers and ensembles of weak estimators in general
You might want to read this: https://roamanalytics.com/2016/10/28/are-categorical-variables-getting-lost-in-your-random-forests/ More on reddit.com
PCA and categorical variables
You could try Sparse PCA: https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.SparsePCA.html More on reddit.com
Categorical variables and Classification
One hot encoding is going to give you such issues. Try feature hashing technique,especially for categorical features with very high cardinality, and put those features directly in logistic regression. You don't need to go through PCA. https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.FeatureHasher.html More on reddit.com
Trainindata
feature-engine.trainindata.com โบ en โบ 1.7.x โบ user_guide โบ encoding
Categorical Encoding โ 1.7.0
The binary variable takes the value 1, if the observation shows the category, or alternatively, 0. One hot encoding is particularly suitable for linear models because it treats each category independently, and linear models can process binary variables effectively.
APXML
apxml.com โบ courses โบ intro-feature-engineering โบ chapter-3-encoding-categorical-features โบ binary-encoding
Binary Encoding Technique
When dealing with categorical features, especially those with many unique values (high cardinality), One-Hot Encoding can lead to a dramatic increase in the number of features, often called the "curse of dimensionality." Binary Encoding offers a compromise: it creates fewer new features than One-Hot Encoding while still capturing the uniqueness of each category more effectively than simple Ordinal Encoding for nominal data.
KDnuggets
kdnuggets.com โบ 2021 โบ 05 โบ deal-with-categorical-data-machine-learning.html
How to Deal with Categorical Data for Machine Learning - KDnuggets
August 4, 2022 - ce_be = ce.BinaryEncoder(cols=['class']); # transform the data data_binary = ce_be.fit_transform(data["class"]); data_binary ... Similarly, there are another 14 types of encoding provided by this library. ... We can assign a prefix if we want to, if we do not want the encoding to use the default. pd.get_dummies(data,prefix=["gen","city"],columns=["gender","city"]) ... Scikit-learn also has 15 different types of built-in encoders, which can be accessed from sklearn.preprocessing. Let's first get the list of categorical variables from our data:
Scikit-learn
contrib.scikit-learn.org โบ category_encoders โบ binary.html
Binary โ Category Encoders 2.11.1 documentation
class category_encoders.binary.BinaryEncoder(verbose=0, cols=None, mapping=None, drop_invariant=False, return_df=True, *, base=2, handle_unknown='value', handle_missing='value', min_group_size: int | float | None = None, min_group_name: str | None = None, combine_min_nan_groups: bool | str | None = None)[source]๏
Read Medium
readmedium.com โบ how-to-use-binary-encoding-to-handle-categorical-variables-in-machine-learning-537c5afb7e77
How to Use Binary Encoding to Handle Categorical Variables in Machine Learning
The tutorial then proceeds through ... binary encoding, and finally examining the encoded data. The category_encoders library's BinaryEncoder class is utilized to transform the categorical data into binary columns, which can be interpreted by machine learning model...