{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Petr Koráb",
  "title_listed": "Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code",
  "keywords": "",
  "domain": "文本处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/",
  "publish_date": "2025-01-23",
  "corpus_stage": "",
  "notes": "",
  "id": "ab9093253930",
  "collected_at": "2026-10-02T03:41:31",
  "title": "Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code | 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# Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code\nA comparison of two cutting-edge dynamic topic models solving consumer complaints classification exercise\n[Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\nJanuary 22, 202511 min read\nTopic Modelling in Business Intelligence: FASTopic and BERTopic in Code\n![Source: Freepic, Image by rawpixel.com](../images/000.jpeg)\nSource: [Freepic](https://www.freepik.com/free-vector/illustration-network-shareing_2808109.htm#fromView=search&page=2&position=3&uuid=c11e1dc6-4be2-45d5-9c7b-29bc16bc69f0), Image by rawpixel.com\n**Customer reviews** about products and services provide valuable information about customer satisfaction. They provide insight into what should be improved across the whole product development. Dynamic topic models in business intelligence can identify key product qualities and other satisfaction factors, cluster them into categories, and evaluate how business decisions materialized in customer satisfaction over time. This is highly valuable information not only for product managers.\nThis article will compare two of the latest topic models to classify customer complaints data. **BERTopic** by [Maarten Grootendorst (2022)](https://arxiv.org/pdf/2203.05794) and the recent [**FASTopic**](https://pypi.org/project/fastopic/) by [Xiaobao Wu et al. (2024)](https://arxiv.org/pdf/2405.17978) presented at last year's [NeurIPS](https://neurips.cc/virtual/2024/poster/96416), are the current leading models for topic analytics of customer data. For these models, we'll explore in Python code:\n  * how to effectively **preprocess data**\n  * how to train a **Bigram topic model** for customer complaint analysis\n  * how to model **topic activity** over time.\n\n\nLearn this step by step with the interactive [Machine Learning](https://roadmap.sh/machine-learning) roadmap.\n# 1. Customer complaints data in companies\nComplaints data are generated by interaction with customers and typically recorded in [ERP systems](https://www.sap.com/products/erp/what-is-erp.html). There are many channels where customers can raise a concern about a product or service. Here are just a few examples:\n  * **Email** : email communication is stored for the BI team, e.g., in the SQL database.\n  * **After-purchase** **survey** : feedback sent to customers after product purchase. Companies either send the emails themselves or use a price comparison website (e.g., [Billiger ](https://www.billiger-mietwagen.de/)in Germany) where customers order the product.\n  * **Phone transcriptions** : after prior consent from a customer, some companies record the phone communication with customers, which is then available for the BI team.\n  * **Google reviews:** customers leave comments and reviews on products and services worldwide. Google enables authorized users to [export the data ](https://takeout.google.com/?pli=1)not only for text mining purposes.\n  * **Review platforms:** independent review platforms **** (such as [Trustpilot](https://www.trustpilot.com/)) offer customers a place to provide feedback to brands and companies. This data is available through [various APIs.](https://developers.trustpilot.com/service-reviews-api)\n  * **Social media** **conversations** : Instagram, X, and Facebook are full of product or brand-related comments. The simplest way is to use an official API to collect the data. For Instagram and Facebook, go to the [developers' portal](https://developers.facebook.com/) to receive an API key. X works the [same way.](https://developer.x.com/en/docs/x-api)\n\n\n## 2. Example data\nAs example data, we'll use the [**Amazon Dog Food Reviews**](https://huggingface.co/datasets/NiyatiC/amazon_food_reviews) dataset from **Hugging Face** , released under the [Apache-2.0 license](https://github.com/huggingface/datasets/blob/main/LICENSE). The subset for topic modeling only contains 3693 customer reviews collected over 02/01/2016: 31/12/2020. Here is what the data looks like:\n![Image 1. Amazon dog food reviews dataset](../images/001.png)\nImage 1. Amazon dog food reviews dataset\n![Image 2. General preprocessing steps for \\(customer feedback\\) topic modeling. Image by author](../images/002.png)\nImage 2. General preprocessing steps for (customer feedback) topic modeling. Image by author\n## 3. Data preprocessing\nProcessing data systematically in the right order keeps the essential information and does not add a new bias. Let's go along these steps:\n  * _**#1: Numbers:**_ digits are typically the characters to remove in the first step.\n  * _**#2: Emoticons:**_ product reviews are typically full of them. For topic modeling in customer reviews, emojis don't have much significance.\n  * _**#3: Stopwords:**_ apart from [standard stopwords](https://www.geeksforgeeks.org/removing-stop-words-nltk-python/), it is common to remove an [extended ](https://github.com/PetrKorab/Arabica/blob/main/stopwords_extended.py)stopwords list for one or more languages.\n  * _**#4: Punctuation:**_ general language has a myriad of special characters and punctuation, which should be cleaned in this step.\n  * _**#5: Additional stopwords:**_ depending on the use case, some additional words are also useful to remove. With the Amazon dog food reviews, these are _\"dog\", \"food\", \"blue\", \"buffalo\", \"ha\", \"month\"_ , and _\"ago\"._\n\n\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 product reviews should always be lemmatized in the last step of preprocessing.\n  * _**#6: Lemmatization:**_ groups words into a single form (the lemma), keeping the word root information and semantics.\n\n\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: The no-code app for text data cleaning**_](https://washer.textminingstories.com/) offering a no-code way of processing data 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\"._ It uses transformers based on real text, not clean text without stopwords, lemmas, or tokens. For this reason, cleaning operations should be included in the model training.\n\n\n![Source: Freepic, Image by macrovector](../images/003.jpeg)\nSource: [Freepic](https://www.freepik.com/free-vector/romantic-train-trip-background_5972223.htm#fromView=search&page=1&position=24&uuid=1b2ccb61-1b56-453e-b67a-befe1eba6858), Image by macrovector\n## 4. Topic modeling with top-notch models\nLet's now check how the satisfaction factors are distributed across the topics. The questions we ask here are:\n  * _What were the key problems and qualities customers reported on the product?_\n  * _How has product satisfaction changed over time?_\n\n\nThe [BERTopi](https://arxiv.org/pdf/2203.05794)c and [FASTopic](https://arxiv.org/pdf/2405.17978) papers describe the model architectures in detail. Also, my [TDS tutorial](https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34) on topic modeling explains topic classification with BERTopic on a political speech dataset.\n### 4.1. FASTopic\nImport the libraries and the data (complete code and the requirements are [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/tree/main)). Then, create a list of clean reviews:\npython\n\n```\nimport pandas as pd\nfrom fastopic import FASTopic\nfrom sklearn.feature_extraction.text import CountVectorizer \nfrom topmost.preprocessing import Preprocessing             \n\n# create a list of reviews\ndocs = data['clean_text'].tolist()\n```\n\nIn FASTopic, bigram generation is not directly implemented. To solve this, we will make a bigram preprocessing class. The model works with bigrams as with individual tokens, so we join the words in bigrams with underscores.\npython\n\n```\n# custom preprocessing class with bigram generation\nclass NgramPreprocessing:\n    def __init__(self, ngram_range=(1, 1), \n                       vocab_size=10000, \n                       stopwords='English'): \n\n        self.ngram_range = ngram_range\n        self.preprocessing = Preprocessing(vocab_size=vocab_size, \n                                           stopwords=stopwords)\n\n        # use a custom analyzer to join bigrams with \"_\"\n        self.vectorizer = CountVectorizer(ngram_range=self.ngram_range, \n                                          max_features=vocab_size, \n                                          analyzer=self._custom_analyzer)\n\n        # custom analyzer function to join bigrams with underscores\n    def _custom_analyzer(self, doc):\n        # tokenize the document and create bigrams\n        tokens = CountVectorizer(ngram_range=self.ngram_range).build_analyzer()(doc)\n\n        # replace spaces in bigrams with \"_\"\n        return [token.replace(\" \", \"_\") for token in tokens]\n\n    def preprocess(self, \n                   docs, \n                   pretrained_WE=False):\n\n        parsed_docs = self.preprocessing.preprocess(docs, \n                      pretrained_WE=pretrained_WE)[\"train_texts\"]\n        train_bow = self.vectorizer.fit_transform(parsed_docs).toarray()\n        rst = {\n            \"train_bow\": train_bow,\n            \"train_texts\": parsed_docs,\n            \"vocab\": self.vectorizer.get_feature_names_out()\n        }\n        return rst\n\n# initialize preprocessing with bigrams\nngram_preprocessing = NgramPreprocessing(ngram_range=(2, 2))\n```\n\nLet's train the model for eight topics and display the top 20 bigrams for each topic in a data frame. We train on single tokens, then remove the underscores generating the bigrams.\npython\n\n```\n# model training\nmodel = FASTopic(8, ngram_preprocessing, num_top_words=10000)\n\n# fit model to documents\ntopic_top_words, doc_topic_dist = model.fit_transform(docs)\n\n# retrieve 20 bigrams for each topic\nimport pandas as pd\n\nmax_bigrams = 20\n\n# Retrieve the bigrams for each topic and select only the word columns\ntopic_0 = pd.DataFrame(model.get_topic(0, max_bigrams), columns=[\"Topic_0_word\", \"Topic_0_prob\"])[[\"Topic_0_word\"]]\ntopic_1 = pd.DataFrame(model.get_topic(1, max_bigrams), columns=[\"Topic_1_word\", \"Topic_1_prob\"])[[\"Topic_1_word\"]]\ntopic_2 = pd.DataFrame(model.get_topic(2, max_bigrams), columns=[\"Topic_2_word\", \"Topic_2_prob\"])[[\"Topic_2_word\"]]\ntopic_3 = pd.DataFrame(model.get_topic(3, max_bigrams), columns=[\"Topic_3_word\", \"Topic_3_prob\"])[[\"Topic_3_word\"]]\ntopic_4 = pd.DataFrame(model.get_topic(4, max_bigrams), columns=[\"Topic_4_word\", \"Topic_4_prob\"])[[\"Topic_4_word\"]]\ntopic_5 = pd.DataFrame(model.get_topic(5, max_bigrams), columns=[\"Topic_5_word\", \"Topic_5_prob\"])[[\"Topic_5_word\"]]\ntopic_6 = pd.DataFrame(model.get_topic(6, max_bigrams), columns=[\"Topic_6_word\", \"Topic_6_prob\"])[[\"Topic_6_word\"]]\ntopic_7 = pd.DataFrame(model.get_topic(7, max_bigrams), columns=[\"Topic_7_word\", \"Topic_7_prob\"])[[\"Topic_7_word\"]]\n\n# concatenate the dataframes\ntopics_df = pd.concat([topic_0,topic_1, topic_2, topic_3, topic_4,topic_5,topic_6,topic_7], axis=1)\n\n# remove underscores from bigrams\ntopics_df = topics_df.applymap(lambda x: x.replace('_', ' ') if isinstance(x, str) else x)\n```\n\nWe've modeled the customer satisfaction factors with a dog food product in eight distinct topics. Here are the manually annotated topic names:\n![Image 3: Satisfaction factors modeling with FASTopic. Image by author](../images/004.png)\nImage 3: Satisfaction factors modeling with FASTopic. Image by author\nFASTopic returns relatively distinct topics, sorting the comments of the customers:\n  * **0: Negative health effects,** _\"sensitive stomach\", \"small bite\", \"stomach issue\", \"lose weight\", \"refuse eat\", \"taste wild\", \"digestive issue\", \"upset stomach\", \"stop eat\", \"gain weight\"_\n  * **1: Food quality,** _\"love flavor\", \"quality ingredient\", \"good ingredient\", \"healthy ingredient\", \"ingredient quality\", \"flavor good\", \"taste great\", \"healthy love\", \"great healthy\", \"good healthy\", \"good health\", ..._\n  * **2: Positive health effects,** _\"healthy fur\", \"awesome pup\", \"eye bright\"_\n  * **3: Digestion effects,** _\"smell bad\", \"runny poop\", \"horrible gas\", \"diarrhea vet\", \"terrible diarrhea,\" \"sick week\", \"sick buy\", \"day vomit\"_\n  * **4: Pricing,** _\"great price\", \"good price\", \"love price\", \"price great\", \"love cheap\", \"price deliver\", \"great deal\", \"price increase\", \"free shipping\", ..._\n  * **5: Other,** other factors.\n  * **6: Fur effects,** _\"coat shiny\", \"fur baby\", \"skin issue\", \"shiny coat\", \"love coat\", \"coat soft\"_\n  * **7: Delivery,** _\"open box\", \"bag rip\", \"big bag\", \"hole bag\", \"open bag\", \"inside box\", \"bag open\", \"bag hole\", \"heavy bag\", \"rip open\", ..._\n\n\nIt is also useful to check the weight of these categories in the data. The full code is [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/blob/main/FASTopic.ipynb).\n> We've modeled the customer satisfaction factors with a dog food product. But why is it beneficial for companies? Dynamic topic models offer a straightforward way of monitoring customer satisfaction over time. They indicate product-related problems and help take the right measures. Once the business decisions are taken into action, topic models check if they have an effect over time.\nTo do so, let's model topic activity over time at a quarterly frequency.\npython\n\n```\nimport plotly.graph_objects as go\n\n# convert date column to datetime\ndata['time'] = pd.to_datetime(data['time'])\n\n# format date column to quarterly periods\ndata['date_quarterly'] = data['time'].dt.to_period('Q').astype(str)\n\nperiods = data['date_quarterly'].tolist()\n\n# calculate topic activity over time\nact = model.topic_activity_over_time(periods)\n\n# visualize topic activity\nfig = model.visualize_topic_activity(top_n=8, topic_activity=act, time_slices=periods)\n\n# update legend to display only the topic number\nfig.data = sorted(fig.data, key=lambda trace: trace.name)\n\nfor trace in fig.data:\n    trace.name = trace.name[0]\n\n# update the layout\nfig.update_layout(\n    width=1200,\n    height=600,\n    title='',\n    legend_title_text='Topic',\n    xaxis_tickangle=45         # set x-axis labels to 45-degree angle\n)\n\n# show the figure\nfig.show()\n```\n\nThe delivery problems in topic 7 peaked in Q3 2018. Customers complained about open and rip boxes much more often, but these problems were fixed in early 2019 (see the picture below).\n![Image 4: Topic activity over time, FASTopic. Image by author.](../images/005.png)\nImage 4: Topic activity over time, FASTopic. Image by author.\n### 4.2. BERTopic\nBERTopic implements bigrams with _[vectorizer_model](https://scikit-learn.org/1.5/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html),_ which also works as a data processing pipeline. The code and the requirements are [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/tree/main).\npython\n\n```\nfrom bertopic import BERTopic\nfrom umap import UMAP\nfrom sklearn.feature_extraction.text import CountVectorizer\nfrom nltk.corpus import stopwords\nimport nltk\nfrom nltk import word_tokenize          \nfrom nltk.stem import WordNetLemmatizer\nimport pandas as pd\nimport re\n\nnltk.download('stopwords')\n\n# create a list of speeches\ndocs = data['text'].tolist()\n```\n\nWe train on raw data and clean it with the vectorizer. During the training, the vectorizer cleans data from numbers and stopwords, returning lemmatized tokens for the bigram model.\npython\n\n```\n# create stopwords list\nstandard_stopwords = list(stopwords.words('english'))\n\n# extended list of English stopwords\nstopwords_extended = [ \"0o\",  ..]      \n\n# additional tokens to remove\nadditional_stopwords = ['blue','buffalo','dog','food','ha','month','ago'] \n\n# combine standard, extended stopwords, and additional tokens\nfull_stopwords = standard_stopwords \n                 + additional_stopwords\n                 + stopwords_extended\n\n# define tokenizer retrurning lemmatized text without numbers\nclass LemmaTokenizer:\n    def __init__(self):\n        self.wnl = WordNetLemmatizer()\n    def __call__(self, doc):\n        doc = re.sub(r'd+', '', doc)  # clean numbers\n        return [self.wnl.lemmatize(t) for t in word_tokenize(doc)] # lemmatize\n\n# vectorizer makes data processing and generates bigrams\nvectorizer_model = CountVectorizer(tokenizer=LemmaTokenizer(),\n                                  ngram_range=(2, 2),\n                                  stop_words=full_stopwords)\n\n# set-up model\nmodel = BERTopic(n_gram_range=(2,2), # returns bigrams\n                nr_topics=9,         # generate 9 topics, leave -1 for outliers\n                top_n_words=20,      # return top 20 bigrams\n                min_topic_size=20,   # topics contains at least 20 tokens\n                vectorizer_model=vectorizer_model,\n                umap_model = UMAP(random_state=1))  # setting seed topics reproduce\n\n# fit model to data\ntopics, probabilities = model.fit_transform(docs)\n```\n\nNext, let's prepare a dataframe with tokens from the model.\npython\n\n```\nimport pandas as pd\n\n# retrieve bigrams for each topic and select only the word columns\ntopic_0 = pd.DataFrame(model.get_topic(0), columns=[\"Topic_0_word\", \"Topic_0_prob\"])[[\"Topic_0_word\"]]\ntopic_1 = pd.DataFrame(model.get_topic(1), columns=[\"Topic_1_word\", \"Topic_1_prob\"])[[\"Topic_1_word\"]]\ntopic_2 = pd.DataFrame(model.get_topic(2), columns=[\"Topic_2_word\", \"Topic_2_prob\"])[[\"Topic_2_word\"]]\ntopic_3 = pd.DataFrame(model.get_topic(3), columns=[\"Topic_3_word\", \"Topic_3_prob\"])[[\"Topic_3_word\"]]\ntopic_4 = pd.DataFrame(model.get_topic(4), columns=[\"Topic_4_word\", \"Topic_4_prob\"])[[\"Topic_4_word\"]]\ntopic_5 = pd.DataFrame(model.get_topic(5), columns=[\"Topic_5_word\", \"Topic_5_prob\"])[[\"Topic_5_word\"]]\ntopic_6 = pd.DataFrame(model.get_topic(6), columns=[\"Topic_6_word\", \"Topic_6_prob\"])[[\"Topic_6_word\"]]\ntopic_7 = pd.DataFrame(model.get_topic(7), columns=[\"Topic_7_word\", \"Topic_7_prob\"])[[\"Topic_7_word\"]]\n\n# concatenate the dataframes\ntopics_df = pd.concat([topic_0, topic_1, topic_2, topic_3, topic_4, \n                       topic_5, topic_6,topic_7], axis=1)\n```\n\nThe annotated topics show similar categorization to FASTopic. The differences are categorizing Spanish tokens into a separate topic (T7) and filling T1 and T5 with adjectives of positive meaning. Delivery problems in T4 are identical to FASTopic's classification.\n![Image 5: Satisfaction factors modeling with BERTopic. Image by author](../images/006.png)\nImage 5: Satisfaction factors modeling with BERTopic. Image by author\nAgain, let's focus on topic activity over time, which gives dynamic topic models additional value for BI. BERTopic uses token frequencies (not topic weights as FASTopic) for topic activity analysis.\npython\n\n```\n# topic activity over time\nimport plotly.graph_objects as go\n\n# create timestamps\ndata['time'] = pd.to_datetime(data['time'])\ntimestamps = data['time'].to_list()\n\n# generate topics over time, 20 bins correspond to Q frequency\ntopics_over_time = model.topics_over_time(docs, timestamps, nr_bins=20)\n\n# filter out topic -1 containing outliers\ntopics_over_time_filtered = topics_over_time[topics_over_time['Topic'] != -1]\n\n# visualize the filtered topics over time\nfig = model.visualize_topics_over_time(topics_over_time_filtered)\n\n# update legend to display only the topic number\nfig.data = sorted(fig.data, key=lambda trace: trace.name)\n\nfor trace in fig.data:\n    trace.name = trace.name[0]\n\n# update the layout\nfig.update_layout(\n    width=1200,\n    height=600,\n    title='',\n    legend_title_text='Topic',\n    xaxis_tickangle=45           # set x-axis labels to 45-degree angle\n)\n\n# show the figure\nfig.show()\n```\n\nMost topics are stable over time, except T4, which categorizes delivery problems. As with FASTopic, BERTopic shows that customers' negative complaints about damaged boxes rose in mid-2018.\n![Image 6: Topic activity over time, BERTopic. Image by author.](../images/007.png)\nImage 6: Topic activity over time, BERTopic. Image by author.\n## Summary\nBoth models indicated delivery problems in mid-2018, which vanished in early 2019. With a topic model API monitoring customer comments on various channels, these problems can be fixed before they have a harmful effect on the brand.\nThe right **data processing is essential** for topic models to make sense in the applied world. Cleaning text in the right order minimizes the bias of each cleaning operation. Numbers and emoticons are typically removed first, followed by stopwords. Punctuation is cleaned afterward so that stopwords don't break up into two tokens (\"we've\" -> \"we\" + 've\"). Additional tokens are removed in the next step in the clean data before lemmatization, which unifies tokens with the same semantics.\n**FASTopic** deserves much better [documentation](https://github.com/BobXWu/FASTopic), which now provides only basic information. Especially because its (1) simplicity of use and (2) stability in training on small datasets makes it a top-notch alternative to BERTopic. It is mainly practical for small companies like e-shops that typically don't collect large text datasets and seek simple and efficient solutions. Data and full codes for this tutorial [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/tree/main).\n_If you enjoy my work, you can invite me_[ _for coffee_](https://www.buymeacoffee.com/petrkorab) _and support my writing. You can also subscribe to my_[ _email list_](https://medium.com/subscribe/@petrkorab) _to get notified about my new articles. Thanks!_\n## References\n[1] Grootendorst (2022). Bertopic: Neural Topic Modeling With A Class-Based TF-IDF Procedure. [_Computer Science._](https://arxiv.org/abs/2203.05794)\n[2] 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## 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[Bertopic](https://towardsdatascience.com/tag/bertopic/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[NLP](https://towardsdatascience.com/tag/nlp/)[Text Mining](https://towardsdatascience.com/tag/text-mining/)[Topic Modelling](https://towardsdatascience.com/tag/topic-modelling/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Ftopic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37%2F&title=Topic%20Modelling%20in%20Business%20Intelligence%3A%20FASTopic%20and%20BERTopic%20in%20Code)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Ftopic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37%2F&title=Topic%20Modelling%20in%20Business%20Intelligence%3A%20FASTopic%20and%20BERTopic%20in%20Code)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Ftopic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37%2F&text=Topic%20Modelling%20in%20Business%20Intelligence%3A%20FASTopic%20and%20BERTopic%20in%20Code)\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/008.png)](https://towardsdatascience.com/dive-into-lora-adapters-38f4da488ede/)\n## [Dive Into LoRA Adapters](https://towardsdatascience.com/dive-into-lora-adapters-38f4da488ede/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nExploring Parameter Efficient Finetuning (PEFT): Intuitively Understanding Finetuning Using LoRA\n[Mariano Kamp](https://towardsdatascience.com/author/mkamp/)\nAugust 25, 202315 min read\n  * [![](../images/009.jpeg)](https://towardsdatascience.com/the-messages-we-send-the-case-against-deploying-machine-learning-3d123a18f13d/)\n## [The Messages We Send: The Case Against \"Deploying\" Machine Learning](https://towardsdatascience.com/the-messages-we-send-the-case-against-deploying-machine-learning-3d123a18f13d/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nWhy Changing Our Language Enables More Responsible AI\n[Ayodele Odubela](https://towardsdatascience.com/author/ayodeleodubela/)\nJune 8, 20214 min read\n  * [![](../images/010.png)](https://towardsdatascience.com/regularization-what-why-when-and-how-d4a329b6b27f/)\n## [Regularization. What, Why, When, and How?](https://towardsdatascience.com/regularization-what-why-when-and-how-d4a329b6b27f/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nIn this article, I want to take an in-depth look at regularization.\n[Akash Shastri](https://towardsdatascience.com/author/akashgshastri/)\nOctober 24, 20205 min read\n  * [![](../images/011.jpeg)](https://towardsdatascience.com/machine-learning-with-googles-bigquery-6602e734bf74/)\n## [Machine Learning with Google's BigQuery](https://towardsdatascience.com/machine-learning-with-googles-bigquery-6602e734bf74/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nHow to easily create and deploy ML Models with SQL\n[Christianlauer](https://towardsdatascience.com/author/christianlauer90/)\nJune 23, 20214 min read\n  * [![](../images/012.png)](https://towardsdatascience.com/pytorch-and-mlx-for-apple-silicon-4f35b9f60e39/)\n## [PyTorch and MLX for Apple Silicon](https://towardsdatascience.com/pytorch-and-mlx-for-apple-silicon-4f35b9f60e39/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA side-by-side CNN implementation and comparison\n[Mike Cvet](https://towardsdatascience.com/author/mikecvet/)\nMarch 8, 20249 min read\n  * [![](../images/body-63beb50f664a055ed739.jpg)](https://towardsdatascience.com/using-complex-networks-to-improve-machine-learning-methods-fe2c034f6de3/)\n## [Using Complex Networks to improve Machine Learning methods](https://towardsdatascience.com/using-complex-networks-to-improve-machine-learning-methods-fe2c034f6de3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUsing the High-Level Data Classification Algorithm to leverage topological characteristics of the data\n[Tiago Toledo Jr.](https://towardsdatascience.com/author/tiagotoledojr/)\nOctober 26, 20216 min read\n  * [![](../images/014.jpeg)](https://towardsdatascience.com/4-useful-clustering-methods-you-should-know-in-2021-ac61301e968e/)\n## [4 Useful clustering methods you should know in 2021](https://towardsdatascience.com/4-useful-clustering-methods-you-should-know-in-2021-ac61301e968e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nForm groups of similar observations based on distance\n[Rukshan Pramoditha](https://towardsdatascience.com/author/rukshanpramoditha/)\nMarch 30, 20217 min read\n  * [![](../images/015.jpg)](https://towardsdatascience.com/what-is-stationarity-in-time-series-and-why-should-you-care-f3b45082356b/)\n## [What is Stationarity in Time Series and why should you care](https://towardsdatascience.com/what-is-stationarity-in-time-series-and-why-should-you-care-f3b45082356b/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nTime Series are Everywhere - Make sure you know how to Handle them\n[Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\nJanuary 11, 20206 min read\n  * [![](../images/016.jpg)](https://towardsdatascience.com/the-machine-learning-advent-calendar-day-13-lasso-and-ridge-regression-in-excel/)\n## [The Machine Learning “Advent Calendar” Day 13: LASSO and Ridge Regression in Excel](https://towardsdatascience.com/the-machine-learning-advent-calendar-day-13-lasso-and-ridge-regression-in-excel/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nWhy regularization is not about changing the model, but about choosing better coefficients\n[Angela and Kezhan Shi](https://towardsdatascience.com/author/angela.shi/)\nDecember 13, 20259 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": "Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code | Towards Data Science",
    "description": "A comparison of two cutting-edge dynamic topic models solving consumer complaints classification exercise",
    "keywords": null,
    "author": "Petr Koráb",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code",
    "og:description": "A comparison of two cutting-edge dynamic topic models solving consumer complaints classification exercise",
    "og:url": "https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1BMLekG4e8DwNWMfQpRy4ag-scaled.jpeg",
    "og:image:width": "2560",
    "og:image:height": "1658",
    "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": "11 min read",
    "article:published_time": "2025-01-22T18:02:13.000Z",
    "article:modified_time": "2025-01-22T18:02:13.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": [
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_000.txt",
      "chars": 235
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_001.txt",
      "chars": 1580
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_002.txt",
      "chars": 1497
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_003.txt",
      "chars": 848
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_004.txt",
      "chars": 355
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_005.txt",
      "chars": 1478
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_006.txt",
      "chars": 1069
    },
    {
      "language": "txt",
      "file": "attachments/ab9093253930/code/block_007.txt",
      "chars": 912
    }
  ],
  "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:11:35Z"
    },
    {
      "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:11:35Z"
    },
    {
      "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:11:35Z"
    },
    {
      "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:11:35Z"
    }
  ],
  "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-with-berttopic-in-python-8a80d529de34"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/bertopic/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/nlp/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/text-mining/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/topic-modelling/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/dive-into-lora-adapters-38f4da488ede/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/deep-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/mkamp/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/the-messages-we-send-the-case-against-deploying-machine-learning-3d123a18f13d/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/ayodeleodubela/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/regularization-what-why-when-and-how-d4a329b6b27f/"
    },
    {
      "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-vector/illustration-network-shareing_2808109.htm"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/2203.05794"
    },
    {
      "type": "external",
      "href": "https://pypi.org/project/fastopic/"
    },
    {
      "type": "external",
      "href": "https://arxiv.org/pdf/2405.17978"
    },
    {
      "type": "external",
      "href": "https://neurips.cc/virtual/2024/poster/96416"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://www.sap.com/products/erp/what-is-erp.html"
    },
    {
      "type": "external",
      "href": "https://www.billiger-mietwagen.de/"
    },
    {
      "type": "external",
      "href": "https://takeout.google.com/?pli=1"
    },
    {
      "type": "external",
      "href": "https://www.trustpilot.com/"
    },
    {
      "type": "external",
      "href": "https://developers.trustpilot.com/service-reviews-api"
    },
    {
      "type": "external",
      "href": "https://developers.facebook.com/"
    },
    {
      "type": "external",
      "href": "https://developer.x.com/en/docs/x-api"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/datasets/NiyatiC/amazon_food_reviews"
    },
    {
      "type": "external",
      "href": "https://github.com/huggingface/datasets/blob/main/LICENSE"
    },
    {
      "type": "external",
      "href": "https://www.geeksforgeeks.org/removing-stop-words-nltk-python/"
    },
    {
      "type": "external",
      "href": "https://github.com/PetrKorab/Arabica/blob/main/stopwords_extended.py"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:34:51Z",
  "source_url": "https://towardsdatascience.com/topic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37/",
  "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# Topic Modelling in Business Intelligence: FASTopic and BERTopic in Code\nA comparison of two cutting-edge dynamic topic models solving consumer complaints classification exercise\n[Petr Koráb](https://towardsdatascience.com/author/petrkorab/)\nJanuary 22, 202511 min read\nTopic Modelling in Business Intelligence: FASTopic and BERTopic in Code\n![Source: Freepic, Image by rawpixel.com](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1BMLekG4e8DwNWMfQpRy4ag-scaled.jpeg)\nSource: [Freepic](https://www.freepik.com/free-vector/illustration-network-shareing_2808109.htm#fromView=search&page=2&position=3&uuid=c11e1dc6-4be2-45d5-9c7b-29bc16bc69f0), Image by rawpixel.com\n**Customer reviews** about products and services provide valuable information about customer satisfaction. They provide insight into what should be improved across the whole product development. Dynamic topic models in business intelligence can identify key product qualities and other satisfaction factors, cluster them into categories, and evaluate how business decisions materialized in customer satisfaction over time. This is highly valuable information not only for product managers.\nThis article will compare two of the latest topic models to classify customer complaints data. **BERTopic** by [Maarten Grootendorst (2022)](https://arxiv.org/pdf/2203.05794) and the recent [**FASTopic**](https://pypi.org/project/fastopic/) by [Xiaobao Wu et al. (2024)](https://arxiv.org/pdf/2405.17978) presented at last year's [NeurIPS](https://neurips.cc/virtual/2024/poster/96416), are the current leading models for topic analytics of customer data. For these models, we'll explore in Python code:\n  * how to effectively **preprocess data**\n  * how to train a **Bigram topic model** for customer complaint analysis\n  * how to model **topic activity** over time.\n\n\nLearn this step by step with the interactive [Machine Learning](https://roadmap.sh/machine-learning) roadmap.\n# 1. Customer complaints data in companies\nComplaints data are generated by interaction with customers and typically recorded in [ERP systems](https://www.sap.com/products/erp/what-is-erp.html). There are many channels where customers can raise a concern about a product or service. Here are just a few examples:\n  * **Email** : email communication is stored for the BI team, e.g., in the SQL database.\n  * **After-purchase** **survey** : feedback sent to customers after product purchase. Companies either send the emails themselves or use a price comparison website (e.g., [Billiger ](https://www.billiger-mietwagen.de/)in Germany) where customers order the product.\n  * **Phone transcriptions** : after prior consent from a customer, some companies record the phone communication with customers, which is then available for the BI team.\n  * **Google reviews:** customers leave comments and reviews on products and services worldwide. Google enables authorized users to [export the data ](https://takeout.google.com/?pli=1)not only for text mining purposes.\n  * **Review platforms:** independent review platforms **** (such as [Trustpilot](https://www.trustpilot.com/)) offer customers a place to provide feedback to brands and companies. This data is available through [various APIs.](https://developers.trustpilot.com/service-reviews-api)\n  * **Social media** **conversations** : Instagram, X, and Facebook are full of product or brand-related comments. The simplest way is to use an official API to collect the data. For Instagram and Facebook, go to the [developers' portal](https://developers.facebook.com/) to receive an API key. X works the [same way.](https://developer.x.com/en/docs/x-api)\n\n\n## 2. Example data\nAs example data, we'll use the [**Amazon Dog Food Reviews**](https://huggingface.co/datasets/NiyatiC/amazon_food_reviews) dataset from **Hugging Face** , released under the [Apache-2.0 license](https://github.com/huggingface/datasets/blob/main/LICENSE). The subset for topic modeling only contains 3693 customer reviews collected over 02/01/2016: 31/12/2020. Here is what the data looks like:\n![Image 1. Amazon dog food reviews dataset](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1eEI-zr7zQNI6Tsau4QW-ww.png)\nImage 1. Amazon dog food reviews dataset\n![Image 2. General preprocessing steps for \\(customer feedback\\) topic modeling. Image by author](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1fIP08_8zJJTRcWAn6DRdiQ.png)\nImage 2. General preprocessing steps for (customer feedback) topic modeling. Image by author\n## 3. Data preprocessing\nProcessing data systematically in the right order keeps the essential information and does not add a new bias. Let's go along these steps:\n  * _**#1: Numbers:**_ digits are typically the characters to remove in the first step.\n  * _**#2: Emoticons:**_ product reviews are typically full of them. For topic modeling in customer reviews, emojis don't have much significance.\n  * _**#3: Stopwords:**_ apart from [standard stopwords](https://www.geeksforgeeks.org/removing-stop-words-nltk-python/), it is common to remove an [extended ](https://github.com/PetrKorab/Arabica/blob/main/stopwords_extended.py)stopwords list for one or more languages.\n  * _**#4: Punctuation:**_ general language has a myriad of special characters and punctuation, which should be cleaned in this step.\n  * _**#5: Additional stopwords:**_ depending on the use case, some additional words are also useful to remove. With the Amazon dog food reviews, these are _\"dog\", \"food\", \"blue\", \"buffalo\", \"ha\", \"month\"_ , and _\"ago\"._\n\n\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 product reviews should always be lemmatized in the last step of preprocessing.\n  * _**#6: Lemmatization:**_ groups words into a single form (the lemma), keeping the word root information and semantics.\n\n\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: The no-code app for text data cleaning**_](https://washer.textminingstories.com/) offering a no-code way of processing data 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\"._ It uses transformers based on real text, not clean text without stopwords, lemmas, or tokens. For this reason, cleaning operations should be included in the model training.\n\n\n![Source: Freepic, Image by macrovector](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/13f-unVEhotrTKCwI-VtWw-scaled.jpeg)\nSource: [Freepic](https://www.freepik.com/free-vector/romantic-train-trip-background_5972223.htm#fromView=search&page=1&position=24&uuid=1b2ccb61-1b56-453e-b67a-befe1eba6858), Image by macrovector\n## 4. Topic modeling with top-notch models\nLet's now check how the satisfaction factors are distributed across the topics. The questions we ask here are:\n  * _What were the key problems and qualities customers reported on the product?_\n  * _How has product satisfaction changed over time?_\n\n\nThe [BERTopi](https://arxiv.org/pdf/2203.05794)c and [FASTopic](https://arxiv.org/pdf/2405.17978) papers describe the model architectures in detail. Also, my [TDS tutorial](https://towardsdatascience.com/topic-modelling-with-berttopic-in-python-8a80d529de34) on topic modeling explains topic classification with BERTopic on a political speech dataset.\n### 4.1. FASTopic\nImport the libraries and the data (complete code and the requirements are [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/tree/main)). Then, create a list of clean reviews:\npython\n\n```\nimport pandas as pd\nfrom fastopic import FASTopic\nfrom sklearn.feature_extraction.text import CountVectorizer \nfrom topmost.preprocessing import Preprocessing             \n\n# create a list of reviews\ndocs = data['clean_text'].tolist()\n```\n\nIn FASTopic, bigram generation is not directly implemented. To solve this, we will make a bigram preprocessing class. The model works with bigrams as with individual tokens, so we join the words in bigrams with underscores.\npython\n\n```\n# custom preprocessing class with bigram generation\nclass NgramPreprocessing:\n    def __init__(self, ngram_range=(1, 1), \n                       vocab_size=10000, \n                       stopwords='English'): \n\n        self.ngram_range = ngram_range\n        self.preprocessing = Preprocessing(vocab_size=vocab_size, \n                                           stopwords=stopwords)\n\n        # use a custom analyzer to join bigrams with \"_\"\n        self.vectorizer = CountVectorizer(ngram_range=self.ngram_range, \n                                          max_features=vocab_size, \n                                          analyzer=self._custom_analyzer)\n\n        # custom analyzer function to join bigrams with underscores\n    def _custom_analyzer(self, doc):\n        # tokenize the document and create bigrams\n        tokens = CountVectorizer(ngram_range=self.ngram_range).build_analyzer()(doc)\n\n        # replace spaces in bigrams with \"_\"\n        return [token.replace(\" \", \"_\") for token in tokens]\n\n    def preprocess(self, \n                   docs, \n                   pretrained_WE=False):\n\n        parsed_docs = self.preprocessing.preprocess(docs, \n                      pretrained_WE=pretrained_WE)[\"train_texts\"]\n        train_bow = self.vectorizer.fit_transform(parsed_docs).toarray()\n        rst = {\n            \"train_bow\": train_bow,\n            \"train_texts\": parsed_docs,\n            \"vocab\": self.vectorizer.get_feature_names_out()\n        }\n        return rst\n\n# initialize preprocessing with bigrams\nngram_preprocessing = NgramPreprocessing(ngram_range=(2, 2))\n```\n\nLet's train the model for eight topics and display the top 20 bigrams for each topic in a data frame. We train on single tokens, then remove the underscores generating the bigrams.\npython\n\n```\n# model training\nmodel = FASTopic(8, ngram_preprocessing, num_top_words=10000)\n\n# fit model to documents\ntopic_top_words, doc_topic_dist = model.fit_transform(docs)\n\n# retrieve 20 bigrams for each topic\nimport pandas as pd\n\nmax_bigrams = 20\n\n# Retrieve the bigrams for each topic and select only the word columns\ntopic_0 = pd.DataFrame(model.get_topic(0, max_bigrams), columns=[\"Topic_0_word\", \"Topic_0_prob\"])[[\"Topic_0_word\"]]\ntopic_1 = pd.DataFrame(model.get_topic(1, max_bigrams), columns=[\"Topic_1_word\", \"Topic_1_prob\"])[[\"Topic_1_word\"]]\ntopic_2 = pd.DataFrame(model.get_topic(2, max_bigrams), columns=[\"Topic_2_word\", \"Topic_2_prob\"])[[\"Topic_2_word\"]]\ntopic_3 = pd.DataFrame(model.get_topic(3, max_bigrams), columns=[\"Topic_3_word\", \"Topic_3_prob\"])[[\"Topic_3_word\"]]\ntopic_4 = pd.DataFrame(model.get_topic(4, max_bigrams), columns=[\"Topic_4_word\", \"Topic_4_prob\"])[[\"Topic_4_word\"]]\ntopic_5 = pd.DataFrame(model.get_topic(5, max_bigrams), columns=[\"Topic_5_word\", \"Topic_5_prob\"])[[\"Topic_5_word\"]]\ntopic_6 = pd.DataFrame(model.get_topic(6, max_bigrams), columns=[\"Topic_6_word\", \"Topic_6_prob\"])[[\"Topic_6_word\"]]\ntopic_7 = pd.DataFrame(model.get_topic(7, max_bigrams), columns=[\"Topic_7_word\", \"Topic_7_prob\"])[[\"Topic_7_word\"]]\n\n# concatenate the dataframes\ntopics_df = pd.concat([topic_0,topic_1, topic_2, topic_3, topic_4,topic_5,topic_6,topic_7], axis=1)\n\n# remove underscores from bigrams\ntopics_df = topics_df.applymap(lambda x: x.replace('_', ' ') if isinstance(x, str) else x)\n```\n\nWe've modeled the customer satisfaction factors with a dog food product in eight distinct topics. Here are the manually annotated topic names:\n![Image 3: Satisfaction factors modeling with FASTopic. Image by author](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1uO8fysZ-mbmaNmpqcnTRcw.png)\nImage 3: Satisfaction factors modeling with FASTopic. Image by author\nFASTopic returns relatively distinct topics, sorting the comments of the customers:\n  * **0: Negative health effects,** _\"sensitive stomach\", \"small bite\", \"stomach issue\", \"lose weight\", \"refuse eat\", \"taste wild\", \"digestive issue\", \"upset stomach\", \"stop eat\", \"gain weight\"_\n  * **1: Food quality,** _\"love flavor\", \"quality ingredient\", \"good ingredient\", \"healthy ingredient\", \"ingredient quality\", \"flavor good\", \"taste great\", \"healthy love\", \"great healthy\", \"good healthy\", \"good health\", ..._\n  * **2: Positive health effects,** _\"healthy fur\", \"awesome pup\", \"eye bright\"_\n  * **3: Digestion effects,** _\"smell bad\", \"runny poop\", \"horrible gas\", \"diarrhea vet\", \"terrible diarrhea,\" \"sick week\", \"sick buy\", \"day vomit\"_\n  * **4: Pricing,** _\"great price\", \"good price\", \"love price\", \"price great\", \"love cheap\", \"price deliver\", \"great deal\", \"price increase\", \"free shipping\", ..._\n  * **5: Other,** other factors.\n  * **6: Fur effects,** _\"coat shiny\", \"fur baby\", \"skin issue\", \"shiny coat\", \"love coat\", \"coat soft\"_\n  * **7: Delivery,** _\"open box\", \"bag rip\", \"big bag\", \"hole bag\", \"open bag\", \"inside box\", \"bag open\", \"bag hole\", \"heavy bag\", \"rip open\", ..._\n\n\nIt is also useful to check the weight of these categories in the data. The full code is [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/blob/main/FASTopic.ipynb).\n> We've modeled the customer satisfaction factors with a dog food product. But why is it beneficial for companies? Dynamic topic models offer a straightforward way of monitoring customer satisfaction over time. They indicate product-related problems and help take the right measures. Once the business decisions are taken into action, topic models check if they have an effect over time.\nTo do so, let's model topic activity over time at a quarterly frequency.\npython\n\n```\nimport plotly.graph_objects as go\n\n# convert date column to datetime\ndata['time'] = pd.to_datetime(data['time'])\n\n# format date column to quarterly periods\ndata['date_quarterly'] = data['time'].dt.to_period('Q').astype(str)\n\nperiods = data['date_quarterly'].tolist()\n\n# calculate topic activity over time\nact = model.topic_activity_over_time(periods)\n\n# visualize topic activity\nfig = model.visualize_topic_activity(top_n=8, topic_activity=act, time_slices=periods)\n\n# update legend to display only the topic number\nfig.data = sorted(fig.data, key=lambda trace: trace.name)\n\nfor trace in fig.data:\n    trace.name = trace.name[0]\n\n# update the layout\nfig.update_layout(\n    width=1200,\n    height=600,\n    title='',\n    legend_title_text='Topic',\n    xaxis_tickangle=45         # set x-axis labels to 45-degree angle\n)\n\n# show the figure\nfig.show()\n```\n\nThe delivery problems in topic 7 peaked in Q3 2018. Customers complained about open and rip boxes much more often, but these problems were fixed in early 2019 (see the picture below).\n![Image 4: Topic activity over time, FASTopic. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1V0TDmxeuw_fxPINZb4mAHw.png)\nImage 4: Topic activity over time, FASTopic. Image by author.\n### 4.2. BERTopic\nBERTopic implements bigrams with _[vectorizer_model](https://scikit-learn.org/1.5/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html),_ which also works as a data processing pipeline. The code and the requirements are [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/tree/main).\npython\n\n```\nfrom bertopic import BERTopic\nfrom umap import UMAP\nfrom sklearn.feature_extraction.text import CountVectorizer\nfrom nltk.corpus import stopwords\nimport nltk\nfrom nltk import word_tokenize          \nfrom nltk.stem import WordNetLemmatizer\nimport pandas as pd\nimport re\n\nnltk.download('stopwords')\n\n# create a list of speeches\ndocs = data['text'].tolist()\n```\n\nWe train on raw data and clean it with the vectorizer. During the training, the vectorizer cleans data from numbers and stopwords, returning lemmatized tokens for the bigram model.\npython\n\n```\n# create stopwords list\nstandard_stopwords = list(stopwords.words('english'))\n\n# extended list of English stopwords\nstopwords_extended = [ \"0o\",  ..]      \n\n# additional tokens to remove\nadditional_stopwords = ['blue','buffalo','dog','food','ha','month','ago'] \n\n# combine standard, extended stopwords, and additional tokens\nfull_stopwords = standard_stopwords \n                 + additional_stopwords\n                 + stopwords_extended\n\n# define tokenizer retrurning lemmatized text without numbers\nclass LemmaTokenizer:\n    def __init__(self):\n        self.wnl = WordNetLemmatizer()\n    def __call__(self, doc):\n        doc = re.sub(r'd+', '', doc)  # clean numbers\n        return [self.wnl.lemmatize(t) for t in word_tokenize(doc)] # lemmatize\n\n# vectorizer makes data processing and generates bigrams\nvectorizer_model = CountVectorizer(tokenizer=LemmaTokenizer(),\n                                  ngram_range=(2, 2),\n                                  stop_words=full_stopwords)\n\n# set-up model\nmodel = BERTopic(n_gram_range=(2,2), # returns bigrams\n                nr_topics=9,         # generate 9 topics, leave -1 for outliers\n                top_n_words=20,      # return top 20 bigrams\n                min_topic_size=20,   # topics contains at least 20 tokens\n                vectorizer_model=vectorizer_model,\n                umap_model = UMAP(random_state=1))  # setting seed topics reproduce\n\n# fit model to data\ntopics, probabilities = model.fit_transform(docs)\n```\n\nNext, let's prepare a dataframe with tokens from the model.\npython\n\n```\nimport pandas as pd\n\n# retrieve bigrams for each topic and select only the word columns\ntopic_0 = pd.DataFrame(model.get_topic(0), columns=[\"Topic_0_word\", \"Topic_0_prob\"])[[\"Topic_0_word\"]]\ntopic_1 = pd.DataFrame(model.get_topic(1), columns=[\"Topic_1_word\", \"Topic_1_prob\"])[[\"Topic_1_word\"]]\ntopic_2 = pd.DataFrame(model.get_topic(2), columns=[\"Topic_2_word\", \"Topic_2_prob\"])[[\"Topic_2_word\"]]\ntopic_3 = pd.DataFrame(model.get_topic(3), columns=[\"Topic_3_word\", \"Topic_3_prob\"])[[\"Topic_3_word\"]]\ntopic_4 = pd.DataFrame(model.get_topic(4), columns=[\"Topic_4_word\", \"Topic_4_prob\"])[[\"Topic_4_word\"]]\ntopic_5 = pd.DataFrame(model.get_topic(5), columns=[\"Topic_5_word\", \"Topic_5_prob\"])[[\"Topic_5_word\"]]\ntopic_6 = pd.DataFrame(model.get_topic(6), columns=[\"Topic_6_word\", \"Topic_6_prob\"])[[\"Topic_6_word\"]]\ntopic_7 = pd.DataFrame(model.get_topic(7), columns=[\"Topic_7_word\", \"Topic_7_prob\"])[[\"Topic_7_word\"]]\n\n# concatenate the dataframes\ntopics_df = pd.concat([topic_0, topic_1, topic_2, topic_3, topic_4, \n                       topic_5, topic_6,topic_7], axis=1)\n```\n\nThe annotated topics show similar categorization to FASTopic. The differences are categorizing Spanish tokens into a separate topic (T7) and filling T1 and T5 with adjectives of positive meaning. Delivery problems in T4 are identical to FASTopic's classification.\n![Image 5: Satisfaction factors modeling with BERTopic. Image by author](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/1vtBKPld2fjsBxlz5bnaqqw.png)\nImage 5: Satisfaction factors modeling with BERTopic. Image by author\nAgain, let's focus on topic activity over time, which gives dynamic topic models additional value for BI. BERTopic uses token frequencies (not topic weights as FASTopic) for topic activity analysis.\npython\n\n```\n# topic activity over time\nimport plotly.graph_objects as go\n\n# create timestamps\ndata['time'] = pd.to_datetime(data['time'])\ntimestamps = data['time'].to_list()\n\n# generate topics over time, 20 bins correspond to Q frequency\ntopics_over_time = model.topics_over_time(docs, timestamps, nr_bins=20)\n\n# filter out topic -1 containing outliers\ntopics_over_time_filtered = topics_over_time[topics_over_time['Topic'] != -1]\n\n# visualize the filtered topics over time\nfig = model.visualize_topics_over_time(topics_over_time_filtered)\n\n# update legend to display only the topic number\nfig.data = sorted(fig.data, key=lambda trace: trace.name)\n\nfor trace in fig.data:\n    trace.name = trace.name[0]\n\n# update the layout\nfig.update_layout(\n    width=1200,\n    height=600,\n    title='',\n    legend_title_text='Topic',\n    xaxis_tickangle=45           # set x-axis labels to 45-degree angle\n)\n\n# show the figure\nfig.show()\n```\n\nMost topics are stable over time, except T4, which categorizes delivery problems. As with FASTopic, BERTopic shows that customers' negative complaints about damaged boxes rose in mid-2018.\n![Image 6: Topic activity over time, BERTopic. Image by author.](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/01/13VYU_pNq_FeIWj0eIjhBVg.png)\nImage 6: Topic activity over time, BERTopic. Image by author.\n## Summary\nBoth models indicated delivery problems in mid-2018, which vanished in early 2019. With a topic model API monitoring customer comments on various channels, these problems can be fixed before they have a harmful effect on the brand.\nThe right **data processing is essential** for topic models to make sense in the applied world. Cleaning text in the right order minimizes the bias of each cleaning operation. Numbers and emoticons are typically removed first, followed by stopwords. Punctuation is cleaned afterward so that stopwords don't break up into two tokens (\"we've\" -> \"we\" + 've\"). Additional tokens are removed in the next step in the clean data before lemmatization, which unifies tokens with the same semantics.\n**FASTopic** deserves much better [documentation](https://github.com/BobXWu/FASTopic), which now provides only basic information. Especially because its (1) simplicity of use and (2) stability in training on small datasets makes it a top-notch alternative to BERTopic. It is mainly practical for small companies like e-shops that typically don't collect large text datasets and seek simple and efficient solutions. Data and full codes for this tutorial [here](https://github.com/PetrKorab/Topic-Modelling-in-Business-Intelligence-BERTopic-and-FASTopic-in-Code/tree/main).\n_If you enjoy my work, you can invite me_[ _for coffee_](https://www.buymeacoffee.com/petrkorab) _and support my writing. You can also subscribe to my_[ _email list_](https://medium.com/subscribe/@petrkorab) _to get notified about my new articles. Thanks!_\n## References\n[1] Grootendorst (2022). Bertopic: Neural Topic Modeling With A Class-Based TF-IDF Procedure. [_Computer Science._](https://arxiv.org/abs/2203.05794)\n[2] 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## 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[Bertopic](https://towardsdatascience.com/tag/bertopic/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[NLP](https://towardsdatascience.com/tag/nlp/)[Text Mining](https://towardsdatascience.com/tag/text-mining/)[Topic Modelling](https://towardsdatascience.com/tag/topic-modelling/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Ftopic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37%2F&title=Topic%20Modelling%20in%20Business%20Intelligence%3A%20FASTopic%20and%20BERTopic%20in%20Code)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Ftopic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37%2F&title=Topic%20Modelling%20in%20Business%20Intelligence%3A%20FASTopic%20and%20BERTopic%20in%20Code)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Ftopic-modelling-in-business-intelligence-fastopic-and-bertopic-in-code-2d3949260a37%2F&text=Topic%20Modelling%20in%20Business%20Intelligence%3A%20FASTopic%20and%20BERTopic%20in%20Code)\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/2023/08/1rLxCaiIBYsFbyECChMWWfg.png)](https://towardsdatascience.com/dive-into-lora-adapters-38f4da488ede/)\n## [Dive Into LoRA Adapters](https://towardsdatascience.com/dive-into-lora-adapters-38f4da488ede/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nExploring Parameter Efficient Finetuning (PEFT): Intuitively Understanding Finetuning Using LoRA\n[Mariano Kamp](https://towardsdatascience.com/author/mkamp/)\nAugust 25, 202315 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/1dpP5L5qqw5S7_su8CmPc0Q-scaled.jpeg)](https://towardsdatascience.com/the-messages-we-send-the-case-against-deploying-machine-learning-3d123a18f13d/)\n## [The Messages We Send: The Case Against \"Deploying\" Machine Learning](https://towardsdatascience.com/the-messages-we-send-the-case-against-deploying-machine-learning-3d123a18f13d/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nWhy Changing Our Language Enables More Responsible AI\n[Ayodele Odubela](https://towardsdatascience.com/author/ayodeleodubela/)\nJune 8, 20214 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/1AkJjUzk4BeCt7JoRU7WL3Q.png)](https://towardsdatascience.com/regularization-what-why-when-and-how-d4a329b6b27f/)\n## [Regularization. What, Why, When, and How?](https://towardsdatascience.com/regularization-what-why-when-and-how-d4a329b6b27f/)\n[Deep Learning](https://towardsdatascience.com/category/artificial-intelligence/deep-learning/)\nIn this article, I want to take an in-depth look at regularization.\n[Akash Shastri](https://towardsdatascience.com/author/akashgshastri/)\nOctober 24, 20205 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/18z2Bt-FeBda9xocbrHhvSQ-scaled.jpeg)](https://towardsdatascience.com/machine-learning-with-googles-bigquery-6602e734bf74/)\n## [Machine Learning with Google's BigQuery](https://towardsdatascience.com/machine-learning-with-googles-bigquery-6602e734bf74/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nHow to easily create and deploy ML Models with SQL\n[Christianlauer](https://towardsdatascience.com/author/christianlauer90/)\nJune 23, 20214 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/03/11NUahuHpvva5q6BuiG51Vg.png)](https://towardsdatascience.com/pytorch-and-mlx-for-apple-silicon-4f35b9f60e39/)\n## [PyTorch and MLX for Apple Silicon](https://towardsdatascience.com/pytorch-and-mlx-for-apple-silicon-4f35b9f60e39/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA side-by-side CNN implementation and comparison\n[Mike Cvet](https://towardsdatascience.com/author/mikecvet/)\nMarch 8, 20249 min read\n  * [![](https://towardsdatascience.com/images/fallback-image.jpg)](https://towardsdatascience.com/using-complex-networks-to-improve-machine-learning-methods-fe2c034f6de3/)\n## [Using Complex Networks to improve Machine Learning methods](https://towardsdatascience.com/using-complex-networks-to-improve-machine-learning-methods-fe2c034f6de3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUsing the High-Level Data Classification Algorithm to leverage topological characteristics of the data\n[Tiago Toledo Jr.](https://towardsdatascience.com/author/tiagotoledojr/)\nOctober 26, 20216 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/1n9GFompLyuI6jJlUjEAUQQ.jpeg)](https://towardsdatascience.com/4-useful-clustering-methods-you-should-know-in-2021-ac61301e968e/)\n## [4 Useful clustering methods you should know in 2021](https://towardsdatascience.com/4-useful-clustering-methods-you-should-know-in-2021-ac61301e968e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nForm groups of similar observations based on distance\n[Rukshan Pramoditha](https://towardsdatascience.com/author/rukshanpramoditha/)\nMarch 30, 20217 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/01/0mawB6nMwRz3KuEwr-scaled.jpg)](https://towardsdatascience.com/what-is-stationarity-in-time-series-and-why-should-you-care-f3b45082356b/)\n## [What is Stationarity in Time Series and why should you care](https://towardsdatascience.com/what-is-stationarity-in-time-series-and-why-should-you-care-f3b45082356b/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nTime Series are Everywhere - Make sure you know how to Handle them\n[Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\nJanuary 11, 20206 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/12/ridge-lasso.jpg)](https://towardsdatascience.com/the-machine-learning-advent-calendar-day-13-lasso-and-ridge-regression-in-excel/)\n## [The Machine Learning “Advent Calendar” Day 13: LASSO and Ridge Regression in Excel](https://towardsdatascience.com/the-machine-learning-advent-calendar-day-13-lasso-and-ridge-regression-in-excel/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nWhy regularization is not about changing the model, but about choosing better coefficients\n[Angela and Kezhan Shi](https://towardsdatascience.com/author/angela.shi/)\nDecember 13, 20259 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/ab9093253930/pages/",
  "body_markdown_path": "attachments/ab9093253930/pages/archived-body.md",
  "local_html": "attachments/ab9093253930/pages/archived-body.html",
  "body_source": "prior_capture"
}