B2B Multiclass Company Classification

Bag of Words - Word Cloud
Feature Importance Chart
LLM vs XGBoost Performance
Comparative Metrics Table

Project Information

  • Category: Data Science & Machine Learning
  • Type: Real-World Multiclass Classification Project (NLP β†’ Tabular Modeling β†’ Generative AI)
  • Status: Completed
  • GitHub: View Repository β†’
Technologies:
Python Pandas Scikit-learn XGBoost NLTK (Bag of Words) OpenAI API (GPT-4o-mini) GridSearchCV

B2B Multiclass Company Classification

This is a real-world project that applies Machine Learning and Natural Language Processing (NLP) techniques to classify companies into four sub-segments (Self-Service, Cash & Carry, Snack Bar, and Bakery). The work addresses a classic market data challenge: semantic ambiguity. The central goal was to resolve vocabulary overlap, where, for example, large wholesale chains and small neighborhood stores use generic terms such as "Supermarket" in their legal names and operate under very similar tax codes. The methodology involved feature engineering (crossing text with CNAE codes and Share Capital) and a robust comparative analysis evolving from Decision Trees to Random Forest and XGBoost, culminating in testing a hybrid architecture with Generative AI (LLMs).

The final model implementation (Optimized XGBoost) achieved a weighted F1-Score of 84% in cross-validation, establishing a new benchmark with 96% precision in identifying wholesalers (Cash & Carry) β€” the business's biggest bottleneck. Beyond delivering a fast, computationally lightweight classifier, the project leveraged GPT-4o-mini as a semantic extractor to diagnose the limitations of the original dataset. This diagnostic step mathematically proved that the absence of the "Trade Name" field in registration databases cost nearly 20 percentage points of performance, strategically directing the company's next steps toward data enrichment at the source, aiming for data maturity and quality.

Key Highlights

  • Strategic Direction: Use of LLM (GPT-4o-mini) not just as a classifier, but as a diagnostic tool to prove that the predictive bottleneck was data maturity and quality (lack of completeness).
  • Surgical Precision on the Bottleneck: The champion model achieved 96% precision on the most critical and challenging business class (Cash & Carry) and 98% recall in total Snack Bar capture.
  • Multi-Feature Engineering: Integration of traditional NLP (Bag of Words) with numerical and categorical features (CNAE and imputed Share Capital) to break the text decision boundary.
  • Statistical Rigor and Validation: Use of Stratified 5-Fold Cross-Validation and GridSearchCV to stabilize metrics, ensure generalization capability, and guarantee architecture robustness against overfitting.
  • Conscious Trade-off: Deep analysis of metrics (Macro vs Weighted Avg, Precision vs Recall) to ensure that the algorithm's mathematical penalization reflected everyday market reality and volume.
  • Algorithmic Benchmarking: Well-founded technical evolution, starting from a simple Baseline (Decision Tree), progressing through Ensembles (Random Forest) to reaching the tabular limit with XGBoost and semantic experimentation with GenAI.