The world’s leading publication for data science, AI, and ML professionals.

Deep Learning Magic: Small Business Type

Corporate intelligence is hard, and NAICS codes are terrible. Some companies buy lists of companies by sector, to keep their leads database…

Corporate intelligence is hard, and NAICS codes are terrible. Some companies buy lists of companies by sector, to keep their leads database up to date (e.g. D+B). The main problems with buying lists is that they are instantly out of date, and they don’t capture small company data well. How can we use machine learning to guess at what a small business does based ONLY on their business name?

Big businesses are generally well-annotated with labels on their company profiles. We can obtain these from free sources or commercial-grade APIs, like Bloomberg and Reuters. Even small cap companies have this data readily available. But small businesses are not so well documented. And making matters worse, most businesses are small. Let’s focus in on small businesses and how we can guess what they do from their name.

As a human, you do this task automatically. You look at the title of a business "Ottawa Corner Mart" and conclude based upon your experience that this is a convenience store. How can we convert from company name to company label? One way we thought would work out great is reading types in the Google Places API. As it turns out, this is one good data source, but not good enough. For the 80%+ of small businesses that Google has no label for, what can we do?

We decided to release a Deep Learning keras model that solves the problem. The DNN model was trained on over 500,000 company names and their associated categories. The company name you want to classify is encoded into a word2vec (gensim) word embedding model trained on ~2.5 million company names. Here is the list of all 127 categories we trained the model to recognize:

We did a lot of design space exploration research to find out the right number of layers and neurons per layer to use in our neural network model.

Trying various model hyperparameters in a shallow search yielded a 1024-neuron wide, 3-layer deep (input, hidden, output) DNN. The model we picked corresponds to the top pink line.
Trying various model hyperparameters in a shallow search yielded a 1024-neuron wide, 3-layer deep (input, hidden, output) DNN. The model we picked corresponds to the top pink line.
The model scored 60% on test data it never saw before. That's pretty good for a 127 class classification problem.
The model scored 60% on test data it never saw before. That’s pretty good for a 127 class classification problem.

It turns out that wide and shallow is the way to go for this model. Here is an example of how the results look on an example dataset:

Here is how you can get your hands on this model (GitHub link):

git clone https://github.com/dcshapiro/smallCompanyType.git
cd smallCompanyType/
pip3 install h5py
pip3 install keras --upgrade
pip3 install tensorflow --upgrade
python3 setup.py install

Here is how you use it:

cd test
python3 test_text.py
python3 test_pandas.py

And just for fun, here is a video showing the successful install on a DigitalOcean Machine Learning droplet. It’s the one-click install image I mentioned in the past few articles I posted.

Can you use this model for commercial purposes? YES. No performance guarantees, but go right ahead. Try it out, and let me know what you think.

Try out the clap tool. Tap that. Follow us on medium. Share a link to this article, or to the GitHub repo. Go for it.

Happy Coding!

-Daniel [email protected] ← Say hi. Lemay.ai 1(855)LEMAY-AI

Other articles you may enjoy:


Related Articles