Skip to main content
QUICK REVIEW

[Paper Review] Encoding Categorical Variables with Conjugate Bayesian Models for WeWork Lead Scoring Engine

Austin Slakey, Daniel Salas|arXiv (Cornell University)|Apr 30, 2019
Time Series Analysis and ForecastingComputer Science20 references11 citations
TL;DR

This paper proposes a conjugate Bayesian model (CBM) encoding technique to handle high-cardinality categorical variables in machine learning, particularly for WeWork's lead scoring engine. By using problem-specific conjugate priors—such as Beta for binary classification—the method transforms categorical features into low-dimensional numerical encodings via analytical posterior updates, achieving a 10x improvement in training speed and boosting AUC from 0.87 to 0.97 on real-world data with up to 346,727 unique categories.

ABSTRACT

Applied Data Scientists throughout various industries are commonly faced with the challenging task of encoding high-cardinality categorical features into digestible inputs for machine learning algorithms. This paper describes a Bayesian encoding technique developed for WeWork's lead scoring engine which outputs the probability of a person touring one of our office spaces based on interaction, enrichment, and geospatial data. We present a paradigm for ensemble modeling which mitigates the need to build complicated preprocessing and encoding schemes for categorical variables. In particular, domain-specific conjugate Bayesian models are employed as base learners for features in a stacked ensemble model. For each column of a categorical feature matrix we fit a problem-specific prior distribution, for example, the Beta distribution for a binary classification problem. In order to analytically derive the moments of the posterior distribution, we update the prior with the conjugate likelihood of the corresponding target variable for each unique value of the given categorical feature. This function of column and value encodes the categorical feature matrix so that the final learner in the ensemble model ingests low-dimensional numerical input. Experimental results on both curated and real world datasets demonstrate impressive accuracy and computational efficiency on a variety of problem archetypes. Particularly, for the lead scoring engine at WeWork -- where some categorical features have as many as 300,000 levels -- we have seen an AUC improvement from 0.87 to 0.97 through implementing conjugate Bayesian model encoding.

Motivation & Objective

  • To address the challenge of encoding high-cardinality categorical features—such as company email domains with 346,727 unique values—into meaningful numerical inputs for machine learning models.
  • To overcome limitations of traditional encoding methods like one-hot encoding, which suffer from sparsity, high dimensionality, and poor generalization to rare or unseen categories.
  • To develop a scalable, computationally efficient, and statistically principled encoding method that supports real-time inference and generalization to rare categories.
  • To evaluate the method’s performance across diverse data types and cardinalities, including real-world lead scoring data and benchmark datasets like PetFinder.
  • To demonstrate that conjugate Bayesian models can serve as effective base learners in stacked ensemble models for improved predictive accuracy and computational efficiency.

Proposed method

  • For each categorical feature, the method fits a problem-specific conjugate prior distribution—e.g., Beta for binary classification, Dirichlet for multinomial outcomes—based on the target variable’s distribution.
  • It computes the posterior distribution analytically by updating the prior with the conjugate likelihood of the target variable for each unique category value, using sufficient statistics from observed data.
  • The resulting posterior mean (or mode) for each category becomes its numerical encoding, reducing high-cardinality features to a low-dimensional, dense representation.
  • These encodings are used as input features for a meta-learner in a stacked ensemble model, where the base learners are trained independently on the transformed data.
  • The method supports generalization to unseen categories by leveraging the prior distribution, which acts as a regularization mechanism for rare or novel values.
  • The approach is computationally efficient because encoding dimensionality remains constant regardless of sample size or cardinality, avoiding the combinatorial explosion of one-hot encoding.

Experimental results

Research questions

  • RQ1Can conjugate Bayesian models effectively encode high-cardinality categorical features while preserving predictive performance and enabling generalization to rare or unseen categories?
  • RQ2How does CBM encoding compare to traditional methods like one-hot and hashing encoding in terms of accuracy, training time, and scalability on large, real-world datasets?
  • RQ3To what extent does the use of conjugate priors improve model generalization in low-sample regimes for rare categorical levels?
  • RQ4Does the method maintain computational efficiency as dataset size and feature cardinality increase, particularly when compared to sparse encoding techniques?
  • RQ5Can problem-specific conjugate priors (e.g., Beta, GIG, Dirichlet) be systematically selected to maximize performance across different machine learning tasks?

Key findings

  • CBM encoding improved the AUC of WeWork’s lead scoring model from 0.87 to 0.97 on a real-world dataset with categorical features having up to 346,727 unique values.
  • The method reduced training time by over 100x compared to scikit-learn’s hashing encoder and showed only marginal increases in computation time as sample size grew.
  • On the PetFinder dataset, the GIG encoder achieved a weighted kappa score of 0.3999, outperforming hashing (0.3777) and one-hot encoding (0.3485) despite lower dimensionality.
  • For the Lead Scoring dataset, the Beta encoder achieved 92.53% accuracy with only 5 dimensions, significantly outperforming one-hot (91.62%) and hashing (91.52%) encoders with higher-dimensional inputs.
  • Training time for CBM encoding increased by less than 1 second when sample size grew from 2,000 to 50,000, whereas one-hot encoding time increased from 10 to over 400 seconds due to rising cardinality and sparsity.
  • The model demonstrated improved accuracy with increasing sample size, in contrast to one-hot encoding, which suffered from accuracy degradation due to the curse of dimensionality.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.