{'fraction_non_alphanumeric': 0.031189555125725337, 'fraction_numerical': 0.011121856866537718, 'mean_word_length': 4.60260751777853, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Sufficient Representations for Categorical Variables

Many learning algorithms require categorical data to be transformed into real vectors before it can be used as input. Often, categorical variables are encoded as one-hot (or dummy) vectors. However, this mode of representation can be wasteful since it adds many low-signal regressors, especially when the number of unique categories is large. In this paper, we investigate simple alternative solutions for universally consistent estimators that rely on lower-dimensional real-valued representations of categorical variables that are"sufficient"in the sense that no predictive information is lost. We then compare preexisting and proposed methods on simulated and observational datasets.


Introduction
Many regression problems involve data collected from a number groups that may be statistically relevant. For example, in a medical setting, we may want to model health outcomes using data on patients from several hospitals and acknowledge that different hospitals may have idiosyncratic effects on patients that are not explained by other covariates. Similar considerations arise when working with data on students from different schools, voters from different zip-codes, employees at different firms, etc.
One of the most wide-spread approaches to this problem is via fixed effect modeling, as follows. Suppose that we observe n samples (X i , G i , Y i ) for i = 1, ..., n, where X i ∈ R p is a set of subject-specific covariates, G i ∈ G is a categorial variable that records group membership and Y i ∈ R is the response of interest, and want to estimate Then, the simple fixed effects approach starts by positing a model µ(x, g) = α g + xβ, and then estimating the coefficients β and α g via ordinary least squares regression. More sophisticated extensions of this approach may involve considering non-linear transformations of x, interactions between group membership and the covariates x, and/or regularization [Angrist and Pischke, 2008, Diggle et al., 2002, Wooldridge, 2010. Figure 1: Causal graph depicting the key assumption that Y i and X i are independent of group membership G i conditionally on latent state L i . The grayed-out nodes are observed.
Fixed effects modeling, however, does not always perform well with complex non-linear signals or when the number of groups |G| is large. The model (2) is quite rigid and may not be able to represent rich signals while, at the same time, the large number of α g parameters in the model (2) may result in problems for statistical inference [Neyman and Scott, 1948]. In other words, the model (2) may have too many parameters to be stable all while lacking the degrees of freedom to fit the signal well.
The goal of this paper is to develop a more parsimonious approach for representing group membership to avoid the above problems. Specifically, we seek a mapping ψ that embeds group membership G i into a k-dimensional space without losing any predictive information, i.e., ψ : G → R k , µ(x, g) = f (x, ψ(g)), such that k is small (in particular, k |G|) and the function f (·, ·) is still easy to learn. Given such a mapping, the problem (1) becomes a routine regression problem with (p + k)-dimensional real-valued features (X i , ψ(G i )), and we can use out-of-the-box statistical learning software on it.
In order to obtain a useful representation of group membership G i , we of course need to assume something about the relationship between G i and the target outcome Y i . The core assumption made in this paper is what we call the sufficient latent state assumption depicted in Figure 1: group membership G i has no direct causal effect on Y i , but may be associated with latent variables L i that do have a direct effect on Y i . For example, in the case of patients spread across hospitals, we assume that hospitals themselves do not directly cause health outcomes Y i ; however, hospitals may still be predictive of Y i through their association with latent causal variables. Patients may have unobserved characteristics, e.g., severity of disease or socioeconomic resources, that both affect Y i and lead the patient to self-select into different hospitals. Our main result is that, under this sufficient latent state assumption, practical representations of the form (3) exist and can be learned from data.
One important application area where regression problems of the form (1) are common arises in causal inference, when we want to measure the effect of a treatment on an outcome of interest while controlling for measured confounders Rubin, 2015, Rosenbaum andRubin, 1983]. In such applications, it is common to have a mix of continuous confounders (e.g., age, income, etc.) and high-cardinality categorical ones (e.g., zip code, hospital, etc.). Given this type of data, modern approaches to causal inference start by solving a series of non-parametric regression problems of the form (1) and then synthetize them into a doubly robust treatment effect estimator; see Athey et al. [2018], Chernozhukov et al. [2018], Robins et al. [1994], van der Laan and Rose [2011] and references therein. Software packages built around this idea include tmle [Gruber and van der Laan, 2012] and grf [Athey et al., 2019] for R [R Core Team, 2019]. As discussed further in Section 5, we expect our approach to predictive modeling with high-cardinality categorical variables to be particularly useful in the context of doubly robust treatment effect estimation.
Our paper is structured as follows. We begin by reviewing similar problem settings in the fixed effects literature and the drawbacks of using existing methods in 1.1. In Section 2, we introduce the primary lemma which seeks to describe the true information we wish to extract from categorical variables. In Section 3, we expand on lemma 1 to develop methods that utilize this insight. In Sections 4 and 5, we run simulated and observational experiments with our proposed methods and follow up with discussion on how realized performance compared to our expectations.

Related Work
The principle of representing high-cardinality categorical variables as real-valued vectors has played an important role in many different areas. For example, in econometrics the categories often represent groups the individual observations belong to (such as classroom cohorts or a region of the country) or are identified by (such as the individual identifier in longitudinal data).
Our work was originally motivated by a result of Arkhangelsky and Imbens [2018], who showed that in many settings where we want to control for a mix of categorical and continuous confounders X i and G i respectively, we don't need to explicitly control for the categorical variable-and it's enough to control for the distribution of the continuous confounders across samples in each category. Furthermore, if the distribution X i G i follows an exponential family, it's enough to control for µ Gi , where µ g = E X i G i = g . In a sense, the results of this paper can be seen as an application of the ideas of Arkhangelsky and Imbens [2018] to the problem of generic predictive modeling.
In natural language processing, it is common to start more complex analyses with a preprocessing step that represent words as vectors that capture the way in which those words are used in context [Mikolov et al., 2013, Pennington et al., 2014. Meanwhile, Cerda et al. [2018] recently consider a related problem of representing "dirty" categorical variables that might arise if, e.g., several categorical levels are just misspellings of each other, and propose using a low-dimensional embedding that exploits lexicographic similarity (i.e., factors with similar spellings are arranged close to each other). In this paper, we use information in the X i , rather than lexicographic information, to construct an embedding; however, the high-level conclusion that we can achieve meaningful gains by using auxiliary information to embed categorical variables in a low-rank space remains. Also, Rahimi and Recht [2008] proposes randomly projecting a one-hot representation of the categorical variables into R k for relatively small k.
Meanwhile, in the literature on panel data analysis, the approach we propose here is perhaps most closely related to the one presented in Bonhomme and Manresa [2015] where individual time series belong to discrete clusters and we have only one fixed effect per cluster (rather than one per time series). Bonhomme and Manresa [2015] then fit this model via a kmeans like algorithm that alternates clustering and estimation with per-cluster fixed effects. Our approach is not directly comparable to either of these methods, as we do not focus on textual data, and do not assume that the latent state L i can be consistently estimated (in contrast, Bonhomme and Manresa [2015] assume that they have access to long enough time series that their clustering step is consistent which, in our setting, would be equivalent to assuming that L i can be recovered).
In the broader machine learning literature, the discussion of how to best account for group membership G i in a non-parametric regression has focused on different ways to encode G i that can be given as an input to statistical software. One simple way to do so is via one-hot encoding: ι : G → {0, 1} M such that the j-th entry of ι(g) is 1 if and only if g corresponds to the j-th element in G, and where M := |G|. Note that linear regression on one-hot encoded features (X i , ι(G i )) exactly recovers the standard fixed effects model (2).
As discussed above, however, one-hot encoding may lead to undesirably high-dimensional problems when M := |G| is large. 1 In the Appendix (7.2), we present multiple encoding methods that similarly project the categories onto R M . These methods do not utilize information from the covariates X i or response Y i and suffer from the same pitfalls that come with high dimensional representation of the observed groups G. The primary difference for these methods are the user's interpretation of the encoded variables which are commonly constructed as the comparison of the mean effect of a subset G ∈ G relative to the mean effect of the set G\G or one of its subsets.
The problem of fixed effects is especially challenging with sparsity-seeking methods such as the lasso [Hastie et al., 2015] or decision trees [Breiman et al., 1984], and related ensemble methods such as random forests [Breiman, 2001] or gradient-boosted trees [Friedman, 2001]. Sparsity-seeking methods will set the contribution of features to zero unless there is strong evidence that those features matter for prediction, and it is difficult for rare levels of G i to produce sufficient evidence to get a non-zero contribution to the model via their one-hot features. The end result is that sparsity seeking methods may largely ignore high-cardinality one-hot encoded factors.
Another prevalent way of working with categorical variables and decision trees is to consider full factorial splits that allow for arbitrary grouping of the levels of the categorical variable. For a variable with M := |G| levels, this allows for 2 M −1 − 1 potential splits. Breiman et al. [1984] showed that we can optimize over this exponential set of potential splits in time that scales linearly in M ; however, from a statistical point of view, such factorial splits are prone to very strong overfitting when the number of levels is large.

Representing Groups with Sufficient Latent State
Our sufficient latent state assumption presented in the introduction and depicted in the causal graph 1 implies that the distribution of the outcome Y i only depends on the observable factor G i through some unobservable latent variable L i . In other words, if we knew the value of L i , then also knowing G i would give us no additional information about the outcome. For a simple example, one may posit that a patient's underlying health status (L i ∈ {good, poor}) may simultaneously determine to which hospital they are admitted (G i ), what symptoms (X i ) they exhibit, and what health outcomes outcomes (Y i ) they attain. Conditioned on the underlying health status, the hospital cannot provide any ad-ditional information about any of the other variables. Conversely, learning their hospital is only helpful inasmuch it allows us to infer something about their health status.
The following lemma states that we can characterize how the information about the categorical variable G i enters the model: the conditional expectation function of the outcome depends only on the conditional probabilities of the latent variable given the observable category. This fact will be crucial when deriving the representation methods in future sections.
Lemma 1. Suppose that the latent state L i is discrete with k possible levels, and that the probabilistic structure required by the sufficient latent state assumption (Figure 1) holds. Then, provides a sufficient representation of G i in the sense of (3): Expression (5) formalizes the intution laid out in the previous paragraph. The information associated with the category only enters the conditional expectation via the set of probabilities P L i = G i = g . If there are only k latent groups, then each category can be represented in a lossless manner by a k dimensional vector of probabilities. An immediate consequence of this result is that if we knew ψ and gave training examples ((X i , ψ(G i )), Y i ) to any universally consistent learner, the learner would eventually recover the optimal prediction function µ(·). To continue the example at the top of this section, the identity of the hospital enters the model through the probability that a patient is in good or poor health given the hospital.
The dependence of the conditional expectation function µ on the latent variable probabilities ψ via (5) is non-linear; however, we will retain consistency if we use an expressive enough method for learning on ((X i , ψ(G i )), Y i ). Methods known to be universally consistent include k-nearest neighbors [Stone, 1977], various tree-based ensembles [Biau et al., 2008], and neural networks [Faragó and Lugosi, 1993].
The discussion above seems to imply that we need to estimate ψ(g) = P [L i |G i = g] directly. However, because this quantity depends on the unobservable variable L i , its identification is impossible without further assumptions and a more sophisticated approach. Instead we pursue a simpler approach by seeking different functions f (g) that depend only on observables (such as f (g) = E[X i |G i = g]), and then proving that they are also sufficient representations because they can be written as invertible functions of ψ(g).

Categorical variable encoding methods
Our methods proposed below take the form of removing the categorical column and replacing it with a set of columns that can be proven to encode all the categorical information. Each method exploiting the structure mentioned in the previous section. For an overview of other categorical encoding methods already in use, please see section 7.2 in the Appendix.

Means encoding
For our first method, we drop the categorical variables G i and substitute in the average value of the continuous regressors X i given the categorical variable. Figure 2 shows an illustration.X   This representation is easily interpretable, and it is simple to implement efficiently. This method may be particularly applicable in instances where the number of regressors p is small relative to the number of categories p |G|, since then the dimensionality reduction is more dramatic as compared to traditional encoding methods such as one-hot encoding. Figure  3 provides an intuitive explanation for why we should expect this to work: the group-wise averages of the continuous variables (X 1 , X 2 ) may reveal the dominant latent group in each category. The next lemma presents the conditions in which this representation provides a sufficient representation. All proofs are in the appendix.
Lemma 2. Under the conditions of Lemma 1, suppose in addition that the matrix A defined by (A) tj := E X it L i = l is left-invertible. Then, the p-dimensional vectors ω(g) := E X i G i = g are sufficient representations of each category in the sense of (3):

Low-rank encodings
The means encoding method may efficiently summarize the effect of the categorical variables if the continuous covariates are reasonably low-dimensional so that p M . When p is large, it might be beneficial to use a lower-dimensional representation of the conditional means. We suggest two low-rank encoding methods, both involving matrix factorization of the transpose of our group-wise means matrix Ω of the continuous covariates where (Ω) jg = E[X ij |G = g].   Figure 4: Implementation example of the low-rank encoding with singular value decomposition. Alternatively, we could also have used sparse PCA in place of SVD.
One alternative is to consider the factorization of the transpose of our p × M group-wise means matrix Ω using singular value decomposition Ω T = U DV T . Then we can use the first k columns of the g th row of the left-singular vector matrix U as the representation for the g th category. Note that in practice, we will be working with the empirical counterpart Ω and k is in general unknown, so we recommend using cross-validation. Figure 4 provides an illustration.
A second low-rank alternative is to use sparse principal component analysis (SPCA) method Zou et al. [2006] instead of SVD. As the name suggests, this method extends the original PCA algorithm by applying an elastic-net-style penalty on the coefficients of the loadings matrix. The result is that the matrix Ω T is approximated by a sparse linear combination of vectors. 3 This sort of sparsity can be advantageous for two reasons. First, sparse PCA creates principal component sparse vectors which can be potentially more interpretable. Second, if our universal estimator is a tree-based model such as random forest Breiman [2001] or xgboost Chen and Guestrin [2016], which fit to data by considering singular covariates at any point in the model, it may have difficulty taking advantage of dense principal components due to the rotation of the original covariate space. That is, if a tree would have been able to produce a good split by using each variable separately, it may not be able to do the same if the variables are combined linearly. On the other hand, sparse PCA requires additional tuning of its regularization parameter λ which can be done via cross-validation.
Lemma 3 shows that if indeed there are only k latent groups, then a representation that uses only the first k columns of the left singular matrix or the first k sparse principal components is indeed sufficient. As with the means method, we rely on the universal consistency property of our estimator to learn a nonlinear mapping.
Lemma 3. Under the conditions of Lemma 1, suppose in addition that the matrix A defined by (A) tj := E X it L i = g is left-invertible. Then, the k-dimensional vectors u(g) := U g,1:k for are sufficient representations of each category in the sense of (3): s.t. A T A = I k×k

Encoding by multinomial logistic regression coefficients
Finally, we propose estimating the conditional probability of category membership by multinomial logistic regression parametrized by coefficients {θ g } g∈G and then use the p-dimensional vector of coefficients θ g associated with the g th category to represent it. The motivation for this method comes from the fact that the prediction model µ(x, g) can be rewritten so that it only depends on the category g through P (G i = g|X i = x), and under the multinomial logistic regression assumption above this boils down to dependence on the θ g coefficients.θ   Figure 5: Implementation example of the mnl encoding.
A related work that also uses regression coefficients as categorical representations is the natural language processing word2vec model of Mikolov et al. [2013]. The authors of word2vec propose two methods to represent words (categories) in a large corpus of text as relatively low-dimensional real-valued vectors. In one of these methods, each word is initially assigned two representations: as a center word v w , and as a surrounding context word v c . Then, the authors posit that the optimal representation is the one that maximizes the log-probability of the inner product of the two representations v T w v c for all pair of words (w, c) that co-occur near each other. Our method works in an analogous way if we let the continuous vectors X i stand in as "contexts", and let θ g ∈ R p represent each category, since then maximizing the log-probability of the inner product X T i θ g is the same as maximizing the multinomial logistic regression above. (25) is leftinvertible, and that P G i = g X i is the multinomial logit distribution with coefficients {θ g } g∈G containing an intercept. Then, the vector θ g ∈ R p is sufficient in the sense of (3):

Lemma 4. Under the conditions of Lemma 1, suppose in addition that A in
Algorithm 4 Multinomial logistic regression method (MNL)

Experiments
In the following section, we explore each method's effectiveness relative to one hot encoding across simulated and real world data sets. We apply two typically used methods: random forests and xgboost. 4

Simulations
We consider two simulations designs that share the distributions of latent groups L i , observable groups G i and covariates X i , but whose outcome models for Y i differ.
Latent groups, observable groups and continuous covariates A latent group L i is drawn uniformly from the set of available groups, which we identify with integers.
Next, observable groups G i are drawn according to the following rule. First, we partition the set of possible observable groups G into equally-sized sets {G } |L| =1 . Then, we draw the observable group G i so that observations that were assigned latent group L 1 have higher probability of falling into observable group G 1 , those in L 2 likely belong to G 2 , and so on. In symbols, Covariates associated with latent group L i = are normally distributed as X i ∼ N (µ , Σ). The mean is zero except for a randomly drawn set of entries J that are −1, +1, with |J | = 3.
Outcomes For the outcome setups, we make each scenario noticeably more complex than the last. In the global linear setup, each latent group has its own intercept while the slope β is the same across latent groups.
where the intercept and slopes are created as follows. The slope normalization ensures that the signal from the intercept, regressors and noise is roughly comparable.
In the latent linear setup, we increase the dependence on the latent groups and the outcome model is linear in regressors conditional on coefficients that are specific to each latent group.
Finally, in the latent piecewise linear setup, we compute a dyadic basis by partitioning each feature X i by its median and then assigning different latent group betas (β + l or β − l ) depending on whether or not the observed X i is above or below its feature's median. Figure 6: Percent Improvement over One Hot Encoding for Regression Forests.

Simulation Results
For each simulated dataset, we estimated the outcome using the various methods described in Section 3, and then evaluated the predictions by their mean squared error. We simulated each simulation setup and model for 200 randomly generated seeds. Results for the simulations are provided in 6. We find that the methods described above which seek to estimate the latent groups consistently outperform methods which require adding |G| additional columns to our input matrix X for both the regression forest and xgboost. In particular, it appears that the sparse low rank approach tends to do well when the number of latent groups is very small. For a larger number of latent groups, we see that low rank approaches underperform and the multinomial and means encoding perform better. We also take note on how the multinomial weight approach potentially does well in this case possibly because n is large and the number of observations per group is high enough to satisfy this approach.
For the methods that do not take advantage of the low rank structure, we notice that the main improvement in performance for regression forests and xgboost occurs due to the reduction in dimensionality. We find that the permutation, fisher, and multiple permutation methods are on average much better than the methods that add |G| columns but still underperform relative to the methods that estimate the latent groups.
While the performance improvements over one hot encoding for 2 latent groups ranges from 1-10%, performance improvement can approach 27-33% for 10 latent groups. Intuitively, we find that this benefit is generally less prevalent for 2 latent groups for regression forests and xgboost due to the lesser complexity of the underlying relationship as defined by the conditional independence graph in 1. The improvement over one hot encoding also tends to increase as the signal becomes more dependent on latent group membership. In most cases, performance on the piecewise linear simulations maintain the same or higher percent improvement over one hot encoding. Furthermore, we find that a more complex and nonlinear method like xgboost benefits slightly less from these encoding methods.

Empirical Applications
We also evaluate these methods on publicly available datasets that are accessible on Kaggle. We run 4 fold, stratified cross validation on the datasets to avoid the case where there are categorical variables in the test set which are not contained in the training set. Since we are throwing out what could potentially be a sizable amount of information with each fold, we also conduct a paired t-test to further validate or deny results seen in the cross validation process.
Pakistan Educational Performance In Hemani [2017], Hemani consolidated a series of surveys from Alif Ailaan, a nonprofit organization in Pakistan that focuses on improving education across the country. The objective of the surveys was to provide an objective means of comparing school systems across cities and provinces in order to spark competition between local governments to spur educational reform.
The dataset used in the analysis below contains n = 580 and 504 after removing null valued rows which can be broken down into |G| = 127 cities from 2013 to 2016. The number of additional covariates p is 20 and further data cleaning and preprocessing details are elaborated upon in the github.
Ames Housing The objective of the Ames Housing Dataset De Cock [2011] was to act as a more complex alternative to the Boston Housing Dataset Harrison and Rubinfeld [1978]. De Cock's aim was to use this dataset for the final project in his regression course which would allow students to more extensively showcase what they had learned.
The Ames Housing Dataset has n = 2, 930 individual home sales in Ames, Iowa from 2006 to 2010. The dataset has 80 covariates and our categorical variable "neighborhood" has |G| = 25.
King County House Sales The King County House Sales Dataset [harlfoxem, 2016] is a data set containing the record of 21,613 home sales in King County, Washington between May 2014 to May 2015. The author does not provide much additional information aside from it being a good dataset to test regression models. The dataset is relatively popular with over 169,000 views and 28,000 downloads at the time of this paper.
The data itself came with 21 covariates including the sale price of the house. We treat the "zipcode" covariate, which has |G| = 70, as the categorical variable.

Empirical Results
We can see that for Regression Forests on average there is an improvement over one hot encoding and xgboost stands to benefit less from using these encoding methods over one hot encoding. For regression forests, the primary case that does not benefit much from these approaches is the Ames data set which follows naturally since the number of covariates p is much larger than the number of observed groups |G|. Therefore, methods such as means and MNL are adding 80 dimensions to the prediction problem while one hot encoding only adds 25. The Low Rank and Sparse Low Rank approaches benefit in these cases and appear to maintain potentially promising results. Contrary to the regression forest results, most of the xgboost output was not statistically significantly different than one hot encoding and the Ames data set was the closest evidence to any benefit. For regression forests, on average, it looks like low rank approaches to generating encodings were most robust across data sets. This could be due to the reduction in dimensionality which may be beneficial for two reasons. First, the underlying relationships were much lower rank than the number of covariates and these methods were able to capture this information. Second, if there was no signal in the categorical variable to begin with, the low rank approaches which utilize K-fold to determine the dimensionality of the encoding are able to pick small k number of encoding vectors to reduce the potential noise covariates one would be adding.

Application to Doubly Robust Treatment Effect Estimation
TODO. We should define the problem with potential outcomes + unconfoundedness; define the DR estimator and briefly summarize its key properties; talk about how our approach to categorical variables fits in; run a simulation + report results.

Conclusion
In this paper, we explore the task of mapping high-cardinality categorical variables G i to a lower-dimensional real space without loss of information relevant to our response Y i . To do this, we make an assumption about the relationship between G i and Y i which we call the sufficient latent state assumption. This assumption provides us with the basis for creating encoding methods which can be used by universally consistent estimators to extract sufficient representations of G i . Among our recommendations for encoding methods, we provide encoding methods which are interpretable or focus more on reducing the size of the R k representation. We find that these methods tend to outperform one hot encoding and other traditional approaches to modeling with categorical variables as the number of unique categories increases.

Proofs
Definitions The following matrices that will be used below.
We denote the columns of Ω as ω(g) and the columns of Ψ as ψ(g).
Overview Proof 7.1.1 shows that categories G i only enter the conditional expectation function µ(x, g) through the latent state probabilities ψ(g). Proofs 7.1.2-7.1.4 rely on strategies for writing ψ(g) = f (h(g)) then showing that h(g) is also a sufficient representation.

Proof of Lemma 1
Proof. To show the equivalence of (1) and (5), we begin by expanding (1) as Now, the conditional independence assumptions encoded in our graph imply that the expectation term simplifies to while the second term can be rewritten using Bayes rule as Combining the above, we see that the mapping µ only depends on the categorical variable through the multivariable function ψ(g) = P [L i |G i = g]. Therefore, ψ(g) is a sufficient representation as defined in (3).
However, note that expression (38) only depends on the category through the mutinomial logit coefficients θ g that are associate with category g. Therefore, under this assumption we can write ω(g) = f (θ g ) =: E[X i |G = g]. However, recall from (33) that if the matrix (A) j := E[X ij |L i = ] has a left-inverse A † A = I, we can write Since ψ(g) only depends on g through θ(g), it follows that θ(g) is also a sufficient representation for the category g.

Additional Encoding Methods
For a more in-depth treatment, see Venables [2016]. Note that several of the methods below are simple linear transformations of each other and should yield equivalent levels of performance in theory. However, as we will see in sections 4.2 and 4.3, in practice the resulting performance can differ substantially.
One-hot or dummy This is the most common categorical encoding, and it is the method we take to be our main baseline, against which we will compare all other methods. It expands out the categorical column into k − 1 columns where k is the number of unique elements in the set of categorical levels in the column. Each column is binary 1 or 0 depending on whether the corresponding level was observed in the original categorical column. [Murphy, 2012, sec 2.3.2] b c d e a 0 0 0 0 b 1 0 0 0 c 0 1 0 0 d 0 0 1 0 e 0 0 0 1 Deviation Similar to one-hot encoding except that the k th unique element's row that is the reference level is now set to all values of −1. This means that categorical levels are being compared to the grand mean of all of the levels instead of the mean of a given level with respect to the reference level. Fisher taken from Hastie et al. [2009], we order the categories by increasing mean of the response.
For the following five methods, we use information about the continuous covariates to construct the mapping ψ.