Introduction
Machine learning models, ranging from linear classifiers to deep neural networks, fundamentally require numerical inputs. However, real-world tabular datasets are frequently dominated by categorical features such as geographic codes, occupations, or industry classifications. Traditional approaches like One-Hot Encoding (OHE) often result in high-dimensional, sparse representations that fail to capture semantic relationships between categories. While embedding techniques like Word2Vec have been adapted for tabular data, they often overlook the global structural dependencies within the dataset.
This paper introduces Graph-based Categorical Embedding (GCE), a novel framework that transforms categorical values into dense numerical vectors by modeling feature co-occurrences as a graph. By utilizing a Differential Pooling (DIFFPool) Graph Neural Network (GNN) architecture, GCE learns embeddings that reflect complex, multi-hop relationships between categories, consistently outperforming standard baselines on tabular classification tasks.
Methodology
The GCE framework operates by converting categorical data into a topological structure and then learning representations through a specialized GNN autoencoder.
1. Graph Construction
Every unique categorical value in the dataset is represented as a node in a "category graph." An edge is established between two nodes if their corresponding values appear together in the same data instance. Edge weights are assigned based on normalized co-occurrence counts, creating a global map of feature interactions.
2. The AutoDIFFPool Architecture
The core of the embedding process is an autoencoder based on Differential Pooling (DIFFPool). While DIFFPool is typically used for hierarchical graph clustering, the authors adapt it to generate feature representations. The model utilizes two parallel GNN components: GNN_embed to compute node embeddings and GNN_pool to generate a soft assignment matrix ($S$).
3. Embedding Extraction
The "soft assignment matrix" ($S$) defines the degree to which each original node (category value) belongs to a set of learned "super-nodes." This mapping serves as the low-dimensional embedding for the category. The network is trained in an unsupervised manner to reconstruct the original co-occurrence adjacency matrix, ensuring that the learned embeddings capture the semantic proximity of features.
Experimental Setup
The authors evaluated GCE against three benchmark datasets from the UCI Machine Learning Repository:
- Banking Data Set (D1): 41,188 instances with 10 categorical features.
- Adult Income Data Set (D2): 48,842 instances with 8 categorical features.
- Census Income Data Set (D3): 199,533 instances with 31 categorical features.
Performance was compared against One-Hot Encoding (OHE), Label Encoding (LE), Word2Vec (W2V), and Node2Vec (N2V) using a logistic regression classifier to isolate the impact of the embedding method.
Results and Discussion
Experimental results demonstrate that GCE provides a superior representation for categorical data in most scenarios. As shown in the performance tables below, GCE achieved the highest ROC AUC scores for the D1 (0.937) and D2 (0.902) datasets.
Key Insights
- Multi-hop Relationships: Unlike Word2Vec, which focuses on immediate context, the GNN-based approach of GCE captures relationships at a deeper distance within the co-occurrence matrix, allowing for a more holistic representation of the data topology.
- The Sparsity Challenge: In the D3 dataset, which features a significantly higher number of categories and sparser overlaps, GCE's performance advantage over Word2Vec was negligible (both at 0.934 ROC AUC). This suggests that graph-based methods are most effective when the underlying co-occurrence graph maintains a certain level of density.
- Efficiency: The study found that an embedding dimension of 30 was optimal, demonstrating that dense graph-based embeddings are significantly more efficient than high-dimensional, sparse OHE vectors.
Conclusion and Future Work
Graph-based Categorical Embedding offers a robust alternative to traditional encoding methods by leveraging the structural information inherent in tabular data. Future research directions include addressing graph sparsity through the use of directed graphs to model hierarchical relationships and transitioning from unsupervised learning to a supervised "task-aware" architecture that incorporates target labels during the embedding phase.
Summary updated