{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Petr Koráb",
  "title_listed": "Choose the Right One: Evaluating Topic Models for Business Intelligence",
  "keywords": "",
  "domain": "文本处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/choose-the-right-one-evaluating-topic-models-for-business-intelligence/",
  "publish_date": "2025-04-24",
  "corpus_stage": "",
  "notes": "",
  "id": "3639ea4bc6f7",
  "collected_at": "2026-10-02T03:38:52",
  "title": "Choose the Right One: Evaluating Topic Models for Business Intelligence | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\n# Choose the Right One: Evaluating Topic Models for Business Intelligence\nPython tutorial for evaluating top-notch bigram topic models in customer email classification\n[Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\nApril 24, 202510 min read\n![](../images/000.jpg)\nSource: [Freepic](https://www.freepik.com/free-photo/pushpins-with-thread-route-map_7727051.htm#fromView=search&page=6&position=5&uuid=b1fd5177-33f1-40e5-b2db-afaec156658f&query=bubble+graph+network+professional)\n**Topic models** are used in businesses to classify brand-related text datasets (such as product and site reviews, surveys, and social media comments) and to track how customer satisfaction metrics change over time.\nThere is a myriad of recent topic models one can choose from: the widely used [BERTopic](https://pypi.org/project/bertopic/) by [Maarten Grootendorst (2022)](https://arxiv.org/pdf/2203.05794), the recent [FASTopic](https://pypi.org/project/fastopic/) presented at last year’s [NeurIPS](https://neurips.cc/virtual/2024/poster/96416), ([Xiaobao Wu et al.,2024)](https://arxiv.org/pdf/2405.17978), the [Dynamic Topic Model](https://bab2min.github.io/tomotopy/v0.13.0/en/#tomotopy.DTModel)by[ Blei and Lafferty (2006](https://arxiv.org/pdf/1602.06049.pdf)), or a fresh semi-supervised [Seeded Poisson Factorization](https://pypi.org/project/seededPF/) model ([Prostmaier et al., 2025](https://arxiv.org/abs/2503.02741)).\nFor a business use case, training topic models on customer texts, we often get results that are not identical and sometimes even conflicting. In business, imperfections cost money, so the engineers should place into production the model that provides the best solution and solves the problem most effectively. At the same pace that new topic models appear on the market, methods for evaluating their quality using new metrics also evolve.\nThis practical tutorial will focus on bigram topic models _,_ which provide more relevant information and identify better key qualities and problems for business decisions than single-word models _(“delivery” vs. “poor delivery”, “stomach” vs. “sensitive stomach”,_ etc.). On one side, bigram models are more detailed; on the other, many evaluation metrics were not originally designed for their evaluation. To provide more background in this area, we will explore in detail:\n  * How to **evaluate the quality of bigram topic models**\n  * How to prepare an **email classification pipeline** in Python.\n\n\nOur example use case will show how bigram topic models ([BERTopic](https://pypi.org/project/bertopic/) and [FASTopic](https://pypi.org/project/fastopic/)) help prioritize email communication with customers on certain topics and reduce response times.\nLearn this step by step with the interactive [Machine Learning](https://roadmap.sh/machine-learning) roadmap.\n## 1. What are topic model quality indicators?\nThe evaluation task should target the ideal state:\n> _The ideal topic model should produce topics where words or bigrams (two consecutive words) in each topic are highly semantically related and distinct for each topic._\nIn practice, this means that the words predicted for each topic are [semantically similar](https://paperswithcode.com/task/semantic-similarity) to human judgment, and there is low duplication of words between topics.\n_It is standard to calculate a set of metrics for each trained model to make a qualified decision on which model to place into production or use for a business decision, comparing the model performance metrics._\n  * **Coherence** metricsevaluate how well the words discovered by a topic model make sense to humans (have [similar semantics](https://www.geeksforgeeks.org/understanding-semantic-analysis-nlp/) in each topic).\n  * **Topic diversity** measures how different the discovered topics are from one another. \n\n\nBigram topic models work well with these metrics:\n  * **NPMI** _(Normalized Point-wise Mutual Information)_ uses probabilities estimated in a reference corpus to calculate a [-1:1] score for each word (or bigram) predicted by the model. Read [[1]](https://arxiv.org/pdf/2401.15351) for more details.\n\n\nThe reference corpus can be either internal (the training set) or external (e.g., an external email dataset). A large, external, and comparable corpus is a better choice because it can help reduce bias in training sets. Because this metric works with word frequencies,**the training set and the reference corpus should be preprocessed the same way**(i.e., if we remove numbers and stopwords in the training set, we should also do it in the reference corpus). The aggregate model score is the average of words across topics. \n  * **SC** _(Semantic Coherence)_ does not need a reference corpus. It uses the same dataset as was used to train the topic model. Read more in [[2](https://aclanthology.org/D11-1024/)].\n\n\nLet’s say we have the Top 4 words for one topic: _“apple”, “banana”, “juice”, “smoothie”_ predicted by a topic model.Then _SC_ looks at all combinations of words in the training set going from left to right, starting with the first word _{apple, banana}_ , _{apple, juice}_ , _{apple, smoothie}_ then the second word _{banana, juice}_ , _{banana, smoothie}_ , then last word _{juice, smoothie}_ and it counts the number of documents that contain both words, divided by the frequency of documents that contain the first word. Overall SC score for a model is the mean of all topic-level scores. \n![](../images/001.png)\nImage 1. Semantic coherence by Mimno et al. (2011) illustration. Image by author.\n**PUV** _(Percentage of Unique Words)_ calculates the share of unique words across topics in the model. _PUV = 1_ means that each topic in the model contains unique bigrams. Values close to 1 indicate a well-shaped, high-quality model with small word overlap between topics. [[3].](https://aclanthology.org/2020.tacl-1.29/)\n> _The_ _**closer to 0 the SC and NIMP scores are**_ _, the more coherent the model is (bigrams predicted by the topic model for each topic are semantically similar). The_ _**closer to 1 PUV is**_ _, the easier the model is to interpret and use, because bigrams between topics do not overlap._\n## 2. How can we prioritize email communication with topic models?\nA large share of customer communication, not only in e-commerce businesses, is now solved with chatbots and personal client sections. Yet, it is common to communicate with customers by email. Many email providers offer developers broad flexibility in APIs to customize their email platform ([_e.g., MailChimp_](https://mailchimp.com/developer/tools/) _,_[_SendGrid_](https://github.com/sendgrid/sendgrid-python) _,_[_Brevo_](https://github.com/getbrevo/brevo-python)). In this place, topic models make mailing more flexible and effective.\n_In this use case, the pipeline takes the input from the incoming emails and uses the trained topic classifier to categorize the incoming email content. The outcome is the classified topic that the Customer Care (CC) Department sees next to each email. The main objective is to allow the CC staff to prioritize the categories of emails and reduce the response time to the most sensitive requests (that directly affect margin-related KPIs or OKRs)._\n![](../images/body-8c701bb34676382c1a8d.png)\nImage 2. Topic model pipeline illustration. Image by author.\n## 3. Data and model set-ups\nWe will train **FASTopic a** nd **BERTopic** to classify emails into 8 and 10 topics and evaluate the quality of all model specifications. Read my previous [TDS tutorial](https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/) on topic modeling with these cutting-edge topic models.\nAs a training set, we use a synthetically generated [Customer Care Email ](https://www.kaggle.com/datasets/rtweera/customer-care-emails)dataset available on Kaggle with a [GPL-3 license](https://www.gnu.org/licenses/gpl-3.0.html). The prefiltered data covers 692 incoming emails and looks like this:\n![](../images/body-f5adce0fb0a4b6bf0e2e.png)\nImage 3. Customer Care Email dataset. Image by author.\n### 3.1. Data preprocessing\nCleaning text in the right order is essential for topic models to work in practice because it minimizes the bias of each cleaning operation. \n**Numbers** are typically removed first, followed by **emojis,** unless we don’t need them for special situations, such as extracting sentiment. [**Stopwords**](https://www.geeksforgeeks.org/removing-stop-words-nltk-python/)for one or more languages are removed afterward, followed by **punctuation** so that stopwords don’t break up into two tokens (_“we’ve”_ -> _“we” + ‘ve”_). **Additional tokens**(company and people’s names, etc.) are removed in the next step in the clean data before [**lemmatization**](https://www.techtarget.com/searchenterpriseai/definition/lemmatization#:~:text=Lemmatization%20is%20the%20process%20of,processing%20%28NLP%29%20and%20chatbots.), which unifies tokens with the same semantics.\n![](../images/body-3709819503f13eee66e0.png)\nImage 4. General preprocessing steps for topic modeling. Image by author\n>  _“Delivery” and “deliveries”, “box” and “Boxes”, or “Price” and “prices” share the same word root, but without lemmatization, topic models would model them as separate factors. That’s why customer emails should be lemmatized in the last step of preprocessing._\nText preprocessing is model-specific:\n  * _**FASTopic**_ works with clean data on input; some cleaning (stopwords) can be done during the training. The simplest and most effective way is to use the [_Washer, a no-code app for text data cleaning_](https://washer.textminingstories.com/)that offers a no-code way of data preprocessing for text mining projects.\n  * _**BERTopic:**_ the [documentation](https://maartengr.github.io/BERTopic/faq.html#how-do-i-reduce-topic-outliers) recommends that “r _emoving stop words as a preprocessing step is not advised as the transformer-based embedding models that we use need the full context to create accurate embeddings”._ For this reason, cleaning operations should be included in the model training.\n\n\n### 3.2. Model compilation and training\nYou can check the full codes for FASTopic and BERTopic’s training with bigram preprocessing and cleaning in [this repo](https://github.com/PetrKorab/Choose-the-Right-One-Evaluating-Topic-Models-for-Business-Intelligence). My previous TDS tutorials [(](https://medium.com/data-science/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37?sk=9a88660d4e4c64a1d91ad8ede730a520)[4](https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/)[)](https://medium.com/data-science/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37?sk=9a88660d4e4c64a1d91ad8ede730a520) and [(](https://medium.com/data-science/topic-modelling-with-berttopic-in-python-8a80d529de34?sk=16ca7ea6c5cdbbc92fead7f9c34c8584)[5](https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34/)[)](https://medium.com/data-science/topic-modelling-with-berttopic-in-python-8a80d529de34?sk=16ca7ea6c5cdbbc92fead7f9c34c8584) explain all steps in detail.\nWe train both models to classify 8 topics in customer email data. A simple inspection of the topic distribution shows that incoming emails to FASTopic are quite well distributed across topics. BERTopic classifies emails unevenly, keeping outliers (uncategorized tokens) in T-1 and a large share of incoming emails in T0.\n![](../images/body-cdb3e75c9daa30acb464.png)\nImage 5: Topic distribution, email classification. Image by author.\nHere are the predicted bigrams for both models with topic labels:\n![](../images/body-a8d3f366be66dd0d4cf4.png)\n![](../images/body-0efcb43e879cd938e0df.png)\nImage 6: Models’ predictions. Image by author.\nBecause the email corpus is a synthetic LLM-generated dataset, the naive labelling of the topics for both models shows topics that are:\n  * **Comparable:**_Time Delays, Latency Issues, User Permissions, Deployment Issues, Compilation Errors,_\n  * **Differing** : _Unclassified_(BERTopic classifies outliers into T-1), _Improvement Suggestions, Authorization Errors, Performance Complaints_(FASTopic), _Cloud Management, Asynchronous Requests, General Requests_ (BERTopic)\n\n\nFor business purposes, topics should be labelled by the company’s insiders who know the customer base and the business priorities.\n## 4. Model evaluation\nIf three out of eight classified topics are labeled differently, then which model should be deployed? Let's now evaluate the coherence and diversity for the trained BERTopic and FASTopic T-8 models.\n### 4.1. NPMI\nWe need a reference corpus to calculate an _NPMI_ for each model. The [Customer IT Support Ticket Dataset](https://www.kaggle.com/datasets/tobiasbueck/multilingual-customer-support-tickets) from Kaggle, distributed with [Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/), provides comparable data to our training set. The data is filtered to 11923 English email bodies. \n  1. _Calculate an NPMI for each bigram in the reference corpus with_[ _this code_](https://github.com/PetrKorab/Choose-the-Right-One-Evaluating-Topic-Models-for-Business-Intelligence/blob/main/NPMI_eval.ipynb) _._\n  2. _Merge bigrams predicted by FASTopic and BERTopic with their NPMI scores from the reference corpus. The fewer NaNs are in the table, the more accurate the metric is._\n\n\n![](../images/body-c7567870db3d83774b20.png)\nImage 7: NPMI coherence evaluation.Image by author.\n_3. Average NPMIs within and across topics to get a single score for each model._\n### 4.2. SC\nWith _SC_ , we learn the context and semantic similarity of bigrams predicted by a topic model by calculating their position in the corpus in relation to other tokens. To do so, we:\n  1. _Create a document-term matrix (DTM) with a count of how many times each bigram appears in each document._\n  2. _Calculate topic SC scores by searching for bigram co-occurrences in the DTM and the bigrams predicted by topic models._\n  3. _Average topic SC to a model SC score._\n\n\n### 4.3. PUV\nTopic diversity _PUV_ metric checks the duplicates of bigrams between topics in a model.\n  1. _Join bigrams into tokens by replacing spaces with underscores in the FASTopic and BERTopic tables of predicted bigrams._\n\n\n![](../images/body-9a60bd21918476da613c.png)\nImage 8: Topic diversity illustration. Image by author.\n_2. Calculate topic diversity as count of distinct tokens/ count of tokens in the tables for both models._\n### 4.4. Model comparison\nLet’s now summarize the coherence and diversity evaluation in Image 9. BERTopic models are more coherent but less diverse than FASTopic. The differences are not very large, but BERTopic suffers from uneven distribution of incoming emails into the pipeline (see charts in Image 5). Around 32% of classified emails fall into _T0_ , and 15% into _T-1_ , which covers the unclassified outliers. The models are trained with a min. of 20 tokens per topic. Increasing this parameter causes the model to be unable to train, probably because of the small data size. \nFor this reason, FASTopic is a better choice for topic modelling in email classification with small training datasets.\n![](../images/body-9bff93a4726bf41ab10e.png)\nImage 9: Topic model evaluation metrics. Image by author.\nThe last step is to deploy the model with topic labels in the email platform to classify incoming emails:\n![](../images/body-c19300bff69c03b6ce64.png)\nImage 10. Topic model classification pipeline, output. Image by author.\n## Summary\nCoherence and diversity metrics compare models with similar training setups, the same dataset, and cleaning strategy. We cannot compare their absolute values with the results of different training sessions. But they help us decide on the best model for our specific use case. They offer a _**relative comparison**_ of various model specifications and help decide which model should be deployed in the pipeline. Topic models evaluation should always be the last step before model deployment in business practice.\nHow does customer care benefit from the topic modelling exercise? After the topic model is put into production, the pipeline sends a classified topic for each email to the email platform that Customer Care uses for communicating with customers. With a limited staff, it is now possible to prioritize and respond faster to the most sensitive business requests (such as _“time delays_ ” and _“latency issues”_), and change priorities dynamically. \nData and complete codes for this tutorial are [here](https://github.com/PetrKorab/Choose-the-Right-One-Evaluating-Topic-Models-for-Business-Intelligence).\n···\n_**Petr Korab**_ _is a Python Engineer and Founder of_[ _Text Mining Stories_](https://textminingstories.com) _with over eight years of experience in Business Intelligence and NLP._\n_**Acknowledgments**_ _: I thank Tomáš Horský (Lentiamo, Prague), Martin Feldkircher, and Viktoriya Teliha (Vienna School of International Studies) for useful comments and suggestions._\n### References\n[1] Blei, D. M., Lafferty, J. D. 2006. Dynamic topic models. In _Proceedings of the 23rd international conference on Machine learning (pp. 113–120)_.\n[2] Dieng A.B., Ruiz F. J. R., and Blei D. M. 2020. Topic modeling in embedding spaces. [Transactions of the Association for Computational Linguistics](https://aclanthology.org/2020.tacl-1.29), 8:439-453.\n[3] Grootendorst, M. 2022. Bertopic: Neural Topic Modeling With A Class-Based TF-IDF Procedure. [_Computer Science._](https://arxiv.org/abs/2203.05794)\n[4] Korab, P. Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code. _Towards Data Science_. 22.1.2025. Accessible from: [link](https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/).\n[5] Korab, P. Topic Modelling with BERTtopic in Python. _Towards Data Science_. 4.1.2024. Accessible from: [link](https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34/).\n[6] Wu, X, Nguyen, T., Ce Zhang, D., Yang Wang, W., Luu, A. T. 2024. [FASTopic: A Fast, Adaptive, Stable, and Transferable Topic Modeling Paradigm](https://arxiv.org/abs/2405.17978). arXiv preprint: 2405.17978.\n[7] Mimno, D., Wallach, H., M., Talley, E., Leenders, M, McCallum. A. 2011. [Optimizing Semantic Coherence in Topic Models.](https://aclanthology.org/D11-1024/) _Proceedings of the 2011 Conference on Empirical Methods in Natural Language Processing._\n[8] Prostmaier, B., Vávra, J., Grün, B., Hofmarcher., P. 2025. [Seeded Poisson Factorization: Leveraging domain knowledge to fit topic models.](https://arxiv.org/abs/2503.02741) arXiv preprint: 2405.17978.\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-9e78938b5e8b0a70213c.jpeg)\nWritten By\n## [Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\n[See all from Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\n[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Bertopic](https://towardsdatascience.com/tag/bertopic/)[Model Evaluation](https://towardsdatascience.com/tag/model-evaluation/)[Text Classification](https://towardsdatascience.com/tag/text-classification/)[Topic Modeling](https://towardsdatascience.com/tag/topic-modeling/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fchoose-the-right-one-evaluating-topic-models-for-business-intelligence%2F&title=Choose%20the%20Right%20One%3A%20Evaluating%20Topic%20Models%20for%20Business%20Intelligence)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fchoose-the-right-one-evaluating-topic-models-for-business-intelligence%2F&title=Choose%20the%20Right%20One%3A%20Evaluating%20Topic%20Models%20for%20Business%20Intelligence)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fchoose-the-right-one-evaluating-topic-models-for-business-intelligence%2F&text=Choose%20the%20Right%20One%3A%20Evaluating%20Topic%20Models%20for%20Business%20Intelligence)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/002.jpg)](https://towardsdatascience.com/how-to-learn-complex-topics-the-right-way-97ca39c4db3e/)\n## [How to Learn Complex Topics the Right Way](https://towardsdatascience.com/how-to-learn-complex-topics-the-right-way-97ca39c4db3e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nOur weekly selection of must-read Editors' Picks and original features\n[TDS Editors](https://towardsdatascience.com/author/towardsdatascience/)\nApril 7, 20223 min read\n  * [![](../images/003.jpg)](https://towardsdatascience.com/neural-graph-databases-cc35c9e1d04f/)\n## [Neural Graph Databases](https://towardsdatascience.com/neural-graph-databases-cc35c9e1d04f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA new milestone in graph data management\n[Michael Galkin](https://towardsdatascience.com/author/mgalkin/)\nMarch 28, 202315 min read\n  * [![](../images/004.png)](https://towardsdatascience.com/analytics-frameworks-every-data-scientist-should-know-f6822f2272af/)\n## [Analytics Frameworks Every Data Scientist Should Know](https://towardsdatascience.com/analytics-frameworks-every-data-scientist-should-know-f6822f2272af/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhy I believe my experience at McKinsey made me a better data scientist\n[Tessa Xie](https://towardsdatascience.com/author/tessaxie/)\nAugust 27, 202410 min read\n  * [![](../images/005.gif)](https://towardsdatascience.com/in-defense-of-weight-sharing-for-neural-architecture-search-an-optimization-perspective-72af458a735e/)\n## [In defense of weight-sharing for neural architecture search: an optimization perspective](https://towardsdatascience.com/in-defense-of-weight-sharing-for-neural-architecture-search-an-optimization-perspective-72af458a735e/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nHow to optimize in the right geometry for provably better, faster neural architecture search.\n[Liam Li](https://towardsdatascience.com/author/liamcli/)\nJuly 16, 202011 min read\n  * [![](../images/006.jpeg)](https://towardsdatascience.com/data-quality-dimensions-in-ibm-watson-knowledge-catalog-79cd0aaf0af2/)\n## [Data quality dimensions in IBM Watson Knowledge Catalog](https://towardsdatascience.com/data-quality-dimensions-in-ibm-watson-knowledge-catalog-79cd0aaf0af2/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nUnderstand the standard data quality dimensions used by IBM Cloud Pak for Data and IBM Infosphere Information Server.\n[Yannick Saillet](https://towardsdatascience.com/author/ysaillet/)\nNovember 13, 202015 min read\n  * [![](../images/007.jpeg)](https://towardsdatascience.com/using-simpleelastix-to-compare-pre-and-post-expansion-microscopy-images-660eaf992482/)\n## [Using SimpleElastix to compare pre- and post-expansion microscopy images](https://towardsdatascience.com/using-simpleelastix-to-compare-pre-and-post-expansion-microscopy-images-660eaf992482/)\n[](https://towardsdatascience.com/choose-the-right-one-evaluating-topic-models-for-business-intelligence/)\nConventional optical microscopy is resolution-limited to about 200nm depending on the wavelength of the used light. Smaller structures can...\n[Dr. Sebastian Reinhard](https://towardsdatascience.com/author/sebastianreinhard/)\nOctober 11, 20214 min read\n  * [![](../images/008.jpg)](https://towardsdatascience.com/why-ai-is-not-stealing-your-job/)\n## [Why AI Is NOT Stealing Your Job](https://towardsdatascience.com/why-ai-is-not-stealing-your-job/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nAI does not decide who gets fired. Companies do.\n[Marco Baity-Jesi](https://towardsdatascience.com/author/marco.baity-jesi/)\nJune 3, 20267 min read\n  * [![](../images/009.png)](https://towardsdatascience.com/understanding-kolmogorov-smirnov-ks-tests-for-data-drift-on-profiled-data-5c8317796f78/)\n## [Understanding Kolmogorov-Smirnov (KS) Tests for Data Drift on Profiled Data](https://towardsdatascience.com/understanding-kolmogorov-smirnov-ks-tests-for-data-drift-on-profiled-data-5c8317796f78/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nData drift meets data profiling\n[Felipe Adachi](https://towardsdatascience.com/author/felipe-p-adachi/)\nDecember 14, 202211 min read\n  * [![](../images/010.jpg)](https://towardsdatascience.com/ensembles-the-almost-free-lunch-in-machine-learning-91af7ebe5090/)\n## [Ensembles: the almost free Lunch in Machine Learning](https://towardsdatascience.com/ensembles-the-almost-free-lunch-in-machine-learning-91af7ebe5090/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nBuild optimal ensembles of neural networks with PyTorch and NumPy\n[Dmitry Borisenko](https://towardsdatascience.com/author/dmitrijborisenko/)\nAugust 14, 202018 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "Choose the Right One: Evaluating Topic Models for Business Intelligence | Towards Data Science",
    "description": "Python tutorial for evaluating top-notch bigram topic models in customer email classification",
    "keywords": null,
    "author": "Petr Koráb",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Choose the Right One: Evaluating Topic Models for Business Intelligence",
    "og:description": "Python tutorial for evaluating top-notch bigram topic models in customer email classification",
    "og:url": "https://towardsdatascience.com/choose-the-right-one-evaluating-topic-models-for-business-intelligence/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/pushpins-with-thread-route-map-scaled-1.jpg",
    "og:image:width": "2560",
    "og:image:height": "1652",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Petr Koráb",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "10 min read",
    "article:published_time": "2025-04-24T13:50:50.000Z",
    "article:modified_time": "2025-04-24T13:50:50.000Z",
    "article:author": "https://towardsdatascience.com/author/petrkorab/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T18:09:22Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T18:09:22Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T18:09:22Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T18:09:22Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/petrkorab/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/bertopic/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/model-evaluation/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/text-classification/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/topic-modeling/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/how-to-learn-complex-topics-the-right-way-97ca39c4db3e/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/towardsdatascience/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/neural-graph-databases-cc35c9e1d04f/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/mgalkin/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/analytics-frameworks-every-data-scientist-should-know-f6822f2272af/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://www.freepik.com/free-photo/pushpins-with-thread-route-map_7727051.htm"
    },
    {
      "type": "external",
      "href": "https://pypi.org/project/bertopic/"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/2203.05794"
    },
    {
      "type": "external",
      "href": "https://pypi.org/project/fastopic/"
    },
    {
      "type": "external",
      "href": "https://neurips.cc/virtual/2024/poster/96416"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/2405.17978"
    },
    {
      "type": "external",
      "href": "https://bab2min.github.io/tomotopy/v0.13.0/en/"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/1602.06049.pdf"
    },
    {
      "type": "external",
      "href": "https://pypi.org/project/seededPF/"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/abs/2503.02741"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://paperswithcode.com/task/semantic-similarity"
    },
    {
      "type": "external",
      "href": "https://www.geeksforgeeks.org/understanding-semantic-analysis-nlp/"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/2401.15351"
    },
    {
      "type": "external",
      "href": "https://aclanthology.org/D11-1024/"
    },
    {
      "type": "external",
      "href": "https://aclanthology.org/2020.tacl-1.29/"
    },
    {
      "type": "external",
      "href": "https://mailchimp.com/developer/tools/"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:33:58Z",
  "source_url": "https://towardsdatascience.com/choose-the-right-one-evaluating-topic-models-for-business-intelligence/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\n# Choose the Right One: Evaluating Topic Models for Business Intelligence\nPython tutorial for evaluating top-notch bigram topic models in customer email classification\n[Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\nApril 24, 202510 min read\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/pushpins-with-thread-route-map-scaled-1.jpg)\nSource: [Freepic](https://www.freepik.com/free-photo/pushpins-with-thread-route-map_7727051.htm#fromView=search&page=6&position=5&uuid=b1fd5177-33f1-40e5-b2db-afaec156658f&query=bubble+graph+network+professional)\n**Topic models** are used in businesses to classify brand-related text datasets (such as product and site reviews, surveys, and social media comments) and to track how customer satisfaction metrics change over time.\nThere is a myriad of recent topic models one can choose from: the widely used [BERTopic](https://pypi.org/project/bertopic/) by [Maarten Grootendorst (2022)](https://arxiv.org/pdf/2203.05794), the recent [FASTopic](https://pypi.org/project/fastopic/) presented at last year’s [NeurIPS](https://neurips.cc/virtual/2024/poster/96416), ([Xiaobao Wu et al.,2024)](https://arxiv.org/pdf/2405.17978), the [Dynamic Topic Model](https://bab2min.github.io/tomotopy/v0.13.0/en/#tomotopy.DTModel)by[ Blei and Lafferty (2006](https://arxiv.org/pdf/1602.06049.pdf)), or a fresh semi-supervised [Seeded Poisson Factorization](https://pypi.org/project/seededPF/) model ([Prostmaier et al., 2025](https://arxiv.org/abs/2503.02741)).\nFor a business use case, training topic models on customer texts, we often get results that are not identical and sometimes even conflicting. In business, imperfections cost money, so the engineers should place into production the model that provides the best solution and solves the problem most effectively. At the same pace that new topic models appear on the market, methods for evaluating their quality using new metrics also evolve.\nThis practical tutorial will focus on bigram topic models _,_ which provide more relevant information and identify better key qualities and problems for business decisions than single-word models _(“delivery” vs. “poor delivery”, “stomach” vs. “sensitive stomach”,_ etc.). On one side, bigram models are more detailed; on the other, many evaluation metrics were not originally designed for their evaluation. To provide more background in this area, we will explore in detail:\n  * How to **evaluate the quality of bigram topic models**\n  * How to prepare an **email classification pipeline** in Python.\n\n\nOur example use case will show how bigram topic models ([BERTopic](https://pypi.org/project/bertopic/) and [FASTopic](https://pypi.org/project/fastopic/)) help prioritize email communication with customers on certain topics and reduce response times.\nLearn this step by step with the interactive [Machine Learning](https://roadmap.sh/machine-learning) roadmap.\n## 1. What are topic model quality indicators?\nThe evaluation task should target the ideal state:\n> _The ideal topic model should produce topics where words or bigrams (two consecutive words) in each topic are highly semantically related and distinct for each topic._\nIn practice, this means that the words predicted for each topic are [semantically similar](https://paperswithcode.com/task/semantic-similarity) to human judgment, and there is low duplication of words between topics.\n_It is standard to calculate a set of metrics for each trained model to make a qualified decision on which model to place into production or use for a business decision, comparing the model performance metrics._\n  * **Coherence** metricsevaluate how well the words discovered by a topic model make sense to humans (have [similar semantics](https://www.geeksforgeeks.org/understanding-semantic-analysis-nlp/) in each topic).\n  * **Topic diversity** measures how different the discovered topics are from one another. \n\n\nBigram topic models work well with these metrics:\n  * **NPMI** _(Normalized Point-wise Mutual Information)_ uses probabilities estimated in a reference corpus to calculate a [-1:1] score for each word (or bigram) predicted by the model. Read [[1]](https://arxiv.org/pdf/2401.15351) for more details.\n\n\nThe reference corpus can be either internal (the training set) or external (e.g., an external email dataset). A large, external, and comparable corpus is a better choice because it can help reduce bias in training sets. Because this metric works with word frequencies,**the training set and the reference corpus should be preprocessed the same way**(i.e., if we remove numbers and stopwords in the training set, we should also do it in the reference corpus). The aggregate model score is the average of words across topics. \n  * **SC** _(Semantic Coherence)_ does not need a reference corpus. It uses the same dataset as was used to train the topic model. Read more in [[2](https://aclanthology.org/D11-1024/)].\n\n\nLet’s say we have the Top 4 words for one topic: _“apple”, “banana”, “juice”, “smoothie”_ predicted by a topic model.Then _SC_ looks at all combinations of words in the training set going from left to right, starting with the first word _{apple, banana}_ , _{apple, juice}_ , _{apple, smoothie}_ then the second word _{banana, juice}_ , _{banana, smoothie}_ , then last word _{juice, smoothie}_ and it counts the number of documents that contain both words, divided by the frequency of documents that contain the first word. Overall SC score for a model is the mean of all topic-level scores. \n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/semantic-coherence-illustration-3.png)\nImage 1. Semantic coherence by Mimno et al. (2011) illustration. Image by author.\n**PUV** _(Percentage of Unique Words)_ calculates the share of unique words across topics in the model. _PUV = 1_ means that each topic in the model contains unique bigrams. Values close to 1 indicate a well-shaped, high-quality model with small word overlap between topics. [[3].](https://aclanthology.org/2020.tacl-1.29/)\n> _The_ _**closer to 0 the SC and NIMP scores are**_ _, the more coherent the model is (bigrams predicted by the topic model for each topic are semantically similar). The_ _**closer to 1 PUV is**_ _, the easier the model is to interpret and use, because bigrams between topics do not overlap._\n## 2. How can we prioritize email communication with topic models?\nA large share of customer communication, not only in e-commerce businesses, is now solved with chatbots and personal client sections. Yet, it is common to communicate with customers by email. Many email providers offer developers broad flexibility in APIs to customize their email platform ([_e.g., MailChimp_](https://mailchimp.com/developer/tools/) _,_[_SendGrid_](https://github.com/sendgrid/sendgrid-python) _,_[_Brevo_](https://github.com/getbrevo/brevo-python)). In this place, topic models make mailing more flexible and effective.\n_In this use case, the pipeline takes the input from the incoming emails and uses the trained topic classifier to categorize the incoming email content. The outcome is the classified topic that the Customer Care (CC) Department sees next to each email. The main objective is to allow the CC staff to prioritize the categories of emails and reduce the response time to the most sensitive requests (that directly affect margin-related KPIs or OKRs)._\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/1c7KCukgLptSzBXYRE2vE_Q.png)\nImage 2. Topic model pipeline illustration. Image by author.\n## 3. Data and model set-ups\nWe will train **FASTopic a** nd **BERTopic** to classify emails into 8 and 10 topics and evaluate the quality of all model specifications. Read my previous [TDS tutorial](https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/) on topic modeling with these cutting-edge topic models.\nAs a training set, we use a synthetically generated [Customer Care Email ](https://www.kaggle.com/datasets/rtweera/customer-care-emails)dataset available on Kaggle with a [GPL-3 license](https://www.gnu.org/licenses/gpl-3.0.html). The prefiltered data covers 692 incoming emails and looks like this:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/1m45AM5Blp2AY-woHy84mxQ.png)\nImage 3. Customer Care Email dataset. Image by author.\n### 3.1. Data preprocessing\nCleaning text in the right order is essential for topic models to work in practice because it minimizes the bias of each cleaning operation. \n**Numbers** are typically removed first, followed by **emojis,** unless we don’t need them for special situations, such as extracting sentiment. [**Stopwords**](https://www.geeksforgeeks.org/removing-stop-words-nltk-python/)for one or more languages are removed afterward, followed by **punctuation** so that stopwords don’t break up into two tokens (_“we’ve”_ -> _“we” + ‘ve”_). **Additional tokens**(company and people’s names, etc.) are removed in the next step in the clean data before [**lemmatization**](https://www.techtarget.com/searchenterpriseai/definition/lemmatization#:~:text=Lemmatization%20is%20the%20process%20of,processing%20%28NLP%29%20and%20chatbots.), which unifies tokens with the same semantics.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/1s5bKzmGiyQ_i-JyOLL4vdQ.png)\nImage 4. General preprocessing steps for topic modeling. Image by author\n>  _“Delivery” and “deliveries”, “box” and “Boxes”, or “Price” and “prices” share the same word root, but without lemmatization, topic models would model them as separate factors. That’s why customer emails should be lemmatized in the last step of preprocessing._\nText preprocessing is model-specific:\n  * _**FASTopic**_ works with clean data on input; some cleaning (stopwords) can be done during the training. The simplest and most effective way is to use the [_Washer, a no-code app for text data cleaning_](https://washer.textminingstories.com/)that offers a no-code way of data preprocessing for text mining projects.\n  * _**BERTopic:**_ the [documentation](https://maartengr.github.io/BERTopic/faq.html#how-do-i-reduce-topic-outliers) recommends that “r _emoving stop words as a preprocessing step is not advised as the transformer-based embedding models that we use need the full context to create accurate embeddings”._ For this reason, cleaning operations should be included in the model training.\n\n\n### 3.2. Model compilation and training\nYou can check the full codes for FASTopic and BERTopic’s training with bigram preprocessing and cleaning in [this repo](https://github.com/PetrKorab/Choose-the-Right-One-Evaluating-Topic-Models-for-Business-Intelligence). My previous TDS tutorials [(](https://medium.com/data-science/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37?sk=9a88660d4e4c64a1d91ad8ede730a520)[4](https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/)[)](https://medium.com/data-science/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37?sk=9a88660d4e4c64a1d91ad8ede730a520) and [(](https://medium.com/data-science/topic-modelling-with-berttopic-in-python-8a80d529de34?sk=16ca7ea6c5cdbbc92fead7f9c34c8584)[5](https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34/)[)](https://medium.com/data-science/topic-modelling-with-berttopic-in-python-8a80d529de34?sk=16ca7ea6c5cdbbc92fead7f9c34c8584) explain all steps in detail.\nWe train both models to classify 8 topics in customer email data. A simple inspection of the topic distribution shows that incoming emails to FASTopic are quite well distributed across topics. BERTopic classifies emails unevenly, keeping outliers (uncategorized tokens) in T-1 and a large share of incoming emails in T0.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/Combined_Topic_Distribution-BERTFAST-1024x352.png)\nImage 5: Topic distribution, email classification. Image by author.\nHere are the predicted bigrams for both models with topic labels:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/FAST-labelled-1024x317.png)\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/BERT-labelled-1024x267.png)\nImage 6: Models’ predictions. Image by author.\nBecause the email corpus is a synthetic LLM-generated dataset, the naive labelling of the topics for both models shows topics that are:\n  * **Comparable:**_Time Delays, Latency Issues, User Permissions, Deployment Issues, Compilation Errors,_\n  * **Differing** : _Unclassified_(BERTopic classifies outliers into T-1), _Improvement Suggestions, Authorization Errors, Performance Complaints_(FASTopic), _Cloud Management, Asynchronous Requests, General Requests_ (BERTopic)\n\n\nFor business purposes, topics should be labelled by the company’s insiders who know the customer base and the business priorities.\n## 4. Model evaluation\nIf three out of eight classified topics are labeled differently, then which model should be deployed? Let's now evaluate the coherence and diversity for the trained BERTopic and FASTopic T-8 models.\n### 4.1. NPMI\nWe need a reference corpus to calculate an _NPMI_ for each model. The [Customer IT Support Ticket Dataset](https://www.kaggle.com/datasets/tobiasbueck/multilingual-customer-support-tickets) from Kaggle, distributed with [Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/), provides comparable data to our training set. The data is filtered to 11923 English email bodies. \n  1. _Calculate an NPMI for each bigram in the reference corpus with_[ _this code_](https://github.com/PetrKorab/Choose-the-Right-One-Evaluating-Topic-Models-for-Business-Intelligence/blob/main/NPMI_eval.ipynb) _._\n  2. _Merge bigrams predicted by FASTopic and BERTopic with their NPMI scores from the reference corpus. The fewer NaNs are in the table, the more accurate the metric is._\n\n\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/14fHYfct2tw5Q3A6VpPZfkg.png)\nImage 7: NPMI coherence evaluation.Image by author.\n_3. Average NPMIs within and across topics to get a single score for each model._\n### 4.2. SC\nWith _SC_ , we learn the context and semantic similarity of bigrams predicted by a topic model by calculating their position in the corpus in relation to other tokens. To do so, we:\n  1. _Create a document-term matrix (DTM) with a count of how many times each bigram appears in each document._\n  2. _Calculate topic SC scores by searching for bigram co-occurrences in the DTM and the bigrams predicted by topic models._\n  3. _Average topic SC to a model SC score._\n\n\n### 4.3. PUV\nTopic diversity _PUV_ metric checks the duplicates of bigrams between topics in a model.\n  1. _Join bigrams into tokens by replacing spaces with underscores in the FASTopic and BERTopic tables of predicted bigrams._\n\n\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/1aqWXAlLUJNtkEYqi8q8LQA.png)\nImage 8: Topic diversity illustration. Image by author.\n_2. Calculate topic diversity as count of distinct tokens/ count of tokens in the tables for both models._\n### 4.4. Model comparison\nLet’s now summarize the coherence and diversity evaluation in Image 9. BERTopic models are more coherent but less diverse than FASTopic. The differences are not very large, but BERTopic suffers from uneven distribution of incoming emails into the pipeline (see charts in Image 5). Around 32% of classified emails fall into _T0_ , and 15% into _T-1_ , which covers the unclassified outliers. The models are trained with a min. of 20 tokens per topic. Increasing this parameter causes the model to be unable to train, probably because of the small data size. \nFor this reason, FASTopic is a better choice for topic modelling in email classification with small training datasets.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/1cn80M85LolcFDDzb2kwjwQ.png)\nImage 9: Topic model evaluation metrics. Image by author.\nThe last step is to deploy the model with topic labels in the email platform to classify incoming emails:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/04/1TbsfZVqkKL6gI2OkVzSZ4w.png)\nImage 10. Topic model classification pipeline, output. Image by author.\n## Summary\nCoherence and diversity metrics compare models with similar training setups, the same dataset, and cleaning strategy. We cannot compare their absolute values with the results of different training sessions. But they help us decide on the best model for our specific use case. They offer a _**relative comparison**_ of various model specifications and help decide which model should be deployed in the pipeline. Topic models evaluation should always be the last step before model deployment in business practice.\nHow does customer care benefit from the topic modelling exercise? After the topic model is put into production, the pipeline sends a classified topic for each email to the email platform that Customer Care uses for communicating with customers. With a limited staff, it is now possible to prioritize and respond faster to the most sensitive business requests (such as _“time delays_ ” and _“latency issues”_), and change priorities dynamically. \nData and complete codes for this tutorial are [here](https://github.com/PetrKorab/Choose-the-Right-One-Evaluating-Topic-Models-for-Business-Intelligence).\n···\n_**Petr Korab**_ _is a Python Engineer and Founder of_[ _Text Mining Stories_](https://textminingstories.com) _with over eight years of experience in Business Intelligence and NLP._\n_**Acknowledgments**_ _: I thank Tomáš Horský (Lentiamo, Prague), Martin Feldkircher, and Viktoriya Teliha (Vienna School of International Studies) for useful comments and suggestions._\n### References\n[1] Blei, D. M., Lafferty, J. D. 2006. Dynamic topic models. In _Proceedings of the 23rd international conference on Machine learning (pp. 113–120)_.\n[2] Dieng A.B., Ruiz F. J. R., and Blei D. M. 2020. Topic modeling in embedding spaces. [Transactions of the Association for Computational Linguistics](https://aclanthology.org/2020.tacl-1.29), 8:439-453.\n[3] Grootendorst, M. 2022. Bertopic: Neural Topic Modeling With A Class-Based TF-IDF Procedure. [_Computer Science._](https://arxiv.org/abs/2203.05794)\n[4] Korab, P. Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code. _Towards Data Science_. 22.1.2025. Accessible from: [link](https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/).\n[5] Korab, P. Topic Modelling with BERTtopic in Python. _Towards Data Science_. 4.1.2024. Accessible from: [link](https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34/).\n[6] Wu, X, Nguyen, T., Ce Zhang, D., Yang Wang, W., Luu, A. T. 2024. [FASTopic: A Fast, Adaptive, Stable, and Transferable Topic Modeling Paradigm](https://arxiv.org/abs/2405.17978). arXiv preprint: 2405.17978.\n[7] Mimno, D., Wallach, H., M., Talley, E., Leenders, M, McCallum. A. 2011. [Optimizing Semantic Coherence in Topic Models.](https://aclanthology.org/D11-1024/) _Proceedings of the 2011 Conference on Empirical Methods in Natural Language Processing._\n[8] Prostmaier, B., Vávra, J., Grün, B., Hofmarcher., P. 2025. [Seeded Poisson Factorization: Leveraging domain knowledge to fit topic models.](https://arxiv.org/abs/2503.02741) arXiv preprint: 2405.17978.\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657190540_3p82kv.jpeg)\nWritten By\n## [Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\n[See all from Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\n[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Bertopic](https://towardsdatascience.com/tag/bertopic/)[Model Evaluation](https://towardsdatascience.com/tag/model-evaluation/)[Text Classification](https://towardsdatascience.com/tag/text-classification/)[Topic Modeling](https://towardsdatascience.com/tag/topic-modeling/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fchoose-the-right-one-evaluating-topic-models-for-business-intelligence%2F&title=Choose%20the%20Right%20One%3A%20Evaluating%20Topic%20Models%20for%20Business%20Intelligence)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fchoose-the-right-one-evaluating-topic-models-for-business-intelligence%2F&title=Choose%20the%20Right%20One%3A%20Evaluating%20Topic%20Models%20for%20Business%20Intelligence)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fchoose-the-right-one-evaluating-topic-models-for-business-intelligence%2F&text=Choose%20the%20Right%20One%3A%20Evaluating%20Topic%20Models%20for%20Business%20Intelligence)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/0Sn33MLlFSHsIk5Hd-scaled.jpg)](https://towardsdatascience.com/how-to-learn-complex-topics-the-right-way-97ca39c4db3e/)\n## [How to Learn Complex Topics the Right Way](https://towardsdatascience.com/how-to-learn-complex-topics-the-right-way-97ca39c4db3e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nOur weekly selection of must-read Editors' Picks and original features\n[TDS Editors](https://towardsdatascience.com/author/towardsdatascience/)\nApril 7, 20223 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/03/1PCbnNVWsqdVx-XWdeAphZA.jpg)](https://towardsdatascience.com/neural-graph-databases-cc35c9e1d04f/)\n## [Neural Graph Databases](https://towardsdatascience.com/neural-graph-databases-cc35c9e1d04f/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA new milestone in graph data management\n[Michael Galkin](https://towardsdatascience.com/author/mgalkin/)\nMarch 28, 202315 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/08/1hu8MIUgTmFIwERvVw7cF-w.png)](https://towardsdatascience.com/analytics-frameworks-every-data-scientist-should-know-f6822f2272af/)\n## [Analytics Frameworks Every Data Scientist Should Know](https://towardsdatascience.com/analytics-frameworks-every-data-scientist-should-know-f6822f2272af/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhy I believe my experience at McKinsey made me a better data scientist\n[Tessa Xie](https://towardsdatascience.com/author/tessaxie/)\nAugust 27, 202410 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/07/0P2kPOPkwZIAcWjXz.gif)](https://towardsdatascience.com/in-defense-of-weight-sharing-for-neural-architecture-search-an-optimization-perspective-72af458a735e/)\n## [In defense of weight-sharing for neural architecture search: an optimization perspective](https://towardsdatascience.com/in-defense-of-weight-sharing-for-neural-architecture-search-an-optimization-perspective-72af458a735e/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nHow to optimize in the right geometry for provably better, faster neural architecture search.\n[Liam Li](https://towardsdatascience.com/author/liamcli/)\nJuly 16, 202011 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/1p_ZdgqVDI3c_hHz1cuZApA.jpeg)](https://towardsdatascience.com/data-quality-dimensions-in-ibm-watson-knowledge-catalog-79cd0aaf0af2/)\n## [Data quality dimensions in IBM Watson Knowledge Catalog](https://towardsdatascience.com/data-quality-dimensions-in-ibm-watson-knowledge-catalog-79cd0aaf0af2/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nUnderstand the standard data quality dimensions used by IBM Cloud Pak for Data and IBM Infosphere Information Server.\n[Yannick Saillet](https://towardsdatascience.com/author/ysaillet/)\nNovember 13, 202015 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/10/1oy6hQoCkKRBNHgKnwooSyA.jpeg)](https://towardsdatascience.com/using-simpleelastix-to-compare-pre-and-post-expansion-microscopy-images-660eaf992482/)\n## [Using SimpleElastix to compare pre- and post-expansion microscopy images](https://towardsdatascience.com/using-simpleelastix-to-compare-pre-and-post-expansion-microscopy-images-660eaf992482/)\n[](https://towardsdatascience.com/choose-the-right-one-evaluating-topic-models-for-business-intelligence/)\nConventional optical microscopy is resolution-limited to about 200nm depending on the wavelength of the used light. Smaller structures can...\n[Dr. Sebastian Reinhard](https://towardsdatascience.com/author/sebastianreinhard/)\nOctober 11, 20214 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2026/06/image2.jpg)](https://towardsdatascience.com/why-ai-is-not-stealing-your-job/)\n## [Why AI Is NOT Stealing Your Job](https://towardsdatascience.com/why-ai-is-not-stealing-your-job/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nAI does not decide who gets fired. Companies do.\n[Marco Baity-Jesi](https://towardsdatascience.com/author/marco.baity-jesi/)\nJune 3, 20267 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/12/1q_wnpvvPgUZB6Bg5PiUj1g.png)](https://towardsdatascience.com/understanding-kolmogorov-smirnov-ks-tests-for-data-drift-on-profiled-data-5c8317796f78/)\n## [Understanding Kolmogorov-Smirnov (KS) Tests for Data Drift on Profiled Data](https://towardsdatascience.com/understanding-kolmogorov-smirnov-ks-tests-for-data-drift-on-profiled-data-5c8317796f78/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nData drift meets data profiling\n[Felipe Adachi](https://towardsdatascience.com/author/felipe-p-adachi/)\nDecember 14, 202211 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/0ykd0KOzS1u-9YWG5-scaled.jpg)](https://towardsdatascience.com/ensembles-the-almost-free-lunch-in-machine-learning-91af7ebe5090/)\n## [Ensembles: the almost free Lunch in Machine Learning](https://towardsdatascience.com/ensembles-the-almost-free-lunch-in-machine-learning-91af7ebe5090/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nBuild optimal ensembles of neural networks with PyTorch and NumPy\n[Dmitry Borisenko](https://towardsdatascience.com/author/dmitrijborisenko/)\nAugust 14, 202018 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "body_base_path": "attachments/3639ea4bc6f7/pages/",
  "body_markdown_path": "attachments/3639ea4bc6f7/pages/archived-body.md",
  "local_html": "attachments/3639ea4bc6f7/pages/archived-body.html",
  "body_source": "prior_capture"
}