保留正文与补采附件。源页面当前未重新核验;具体限制见交付清单。

Revisit consent button We value your privacy We 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. Customise Reject All Accept All Customise Consent Preferences We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below. The 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 NecessaryAlways Active Necessary 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.

Functional Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

Analytics Analytical 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.

Performance Performance 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.

Advertisement Advertisement 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.

Uncategorised Other uncategorised cookies are those that are being analysed and have not been classified into a category as yet. No cookies to display. Reject All Save My Preferences Accept All Toggle SearchToggle Mobile Navigation Publish AI, ML & data-science insights to a global community of data professionals. Sign inSubmit an Article LatestEditor's PicksNewsletterShipAI


Write For TDS LinkedInXToggle Search Data Science

Bigram Word Cloud Animates Your Data Stories

Hands-on tutorial explaining how to create an Animated Word Cloud of bigram frequencies to display a text dataset in an MP4 video Petr Koráb May 8, 20245 min read

Hands-on tutorial explaining how to create an Animated Word Cloud of bigram frequencies to display a text dataset in an MP4 video

Source: AnimatedWordCloud library. Image by Author. Source: AnimatedWordCloud library. Image by Author. Animated word cloud displays n-gram frequencies (words and consequent words in a text corpus) over time as a sequence of images in a video file. **** I** tgives greater importance to words that appear more frequently in a source text, but it scales the dataset to work with different datasets. The original visualization method uses the intuitive logic of classicword cloudsand adds a time dimension to the graph. It has been designed to explore text datasets collected over multiple periods (referred to as __ "time-series text data"**). Michael Kane developed the core framework for animating word frequencies, and the AnimatedWordCloud (AWC) library implemented the visualization method into practice. __ The new release brings important updates:

This article will give a glimpse of how to create a bigram-animated word cloud from a text dataset of product reviews. Read my main framework and unigram tutorials to learn more about animated word clouds.

2. Use cases

Earlier releases of the AWC were already used to tell the stories of:

Please accept cookies to access this content

Please accept cookies to access this content

3. Bigram Animated Word Cloud

3.1. How to install the library

Install the library in a new Python 3.8 virtual environment to avoid dependence conflicts. It relies on Python 3.8 because of its visualization requirements. To install using pip, use: python

pip install AnimatedWordCloud

3.2. Data

For the AWC bigram exercise, we'll use the Amazon Dog Food Reviews dataset from the Hugging Face , released under the Apache-2.0 license. The example subset covers 305 reviews from 2020-01-01 to 2021-04-16 and can be downloaded from here. Here is what the data looks like: Image 3. Amazon dog food reviews dataset Image 3. Amazon dog food reviews dataset

3.3. Product review analysis

Product reviews are very useful sources of information for companies because they contain qualitative information about the customers' satisfaction with products (or services). Text mining analysis can reveal bigrams with positive and negative meanings , and also bigrams that indicate important factors of product satisfaction. Read my previous TDS article about customer satisfaction measurement with n-gram and sentiment analysis to learn more.

Finding a high frequency of bigrams with positive meanings, e.g., "highly satisfied", "fast delivery," or "great service" and bigrams with negative meanings, e.g., "poor quality" or "damaged products" might indicate import problems hampering the company's growth. Now, let's generate a Bigram animated word cloud for the text reviews in monthly frequency , cleaning data from English stopwords and also cutting out other redundant strings ('years old', 'year old', 'every day', 'Amazon'): The code creates 200 PNG word cloud images per period. The frames are stored in the working directory in the newly created _.post processing/frames folder. Next, download the ffmpeg folder and the frames2video.bat file from here and place them into the postprocessing folder. Running the frames2video.bat generates a wordSwarmOut.mp4 video file. The video is on my YouTube: Please accept cookies to access this content The brand associated with the reviews appears to be Blue Buffalo. We can see large frequencies of bigrams with positive meanings - "dog loves ", "dog likes ", and "love food " until Oct 2020. The associated qualities are price ("good price ") and product quality ("life protection "). Since Dec 2020, there seem to be negative health effects of the products ("bloody vomit ", "vomit stool, " "heart disease ," "vomiting diarrhea "). In this situation, the company should check the production line and the delivery process to find out the reasons.

Conclusions

Animated Word Cloud is an original text visualization method for datasets with time variability. The library is a result of applied text-mining research. Originally developed by Michael Kane, the Python implementation relies on the preprocessing of the Arabica library, which is now forthcoming in the Journal of Open Source Software (Koráb, Poměnková, 2024). The library is still under development. Let's mention several drawbacks of using the AWC for time-series text visualization:

Color, word positions, and other parameters are generated for each trial . In certain trials, the words might overlap, lowering the quality of the data story. Therefore, it is helpful to create a couple of videos, compare the visuals, and select the nicest one.

The library has been tested and optimized to work with datasets of various sizes, periods, and word frequencies, but it is still under development. If you find any visualization issues that hamper the video quality, please open an issue here to get it improved.

Skip removes strings as they are and does not consider tokenization of the dataset. Removing strings such as "Mar" might lead to a bias because a bigram "Mario Braghi" then might become "io Braghi". In practical situations, it is useful to use the skip parameter to remove complicated strings such as:_skip = ['https://1236578995.org/@789', '@JaayZen/']_


If you enjoy my work, you can invite me for coffee and support my writing. You can also subscribe to my email list to get notified about my new articles. Thanks!

References

[1] Koráb, & Poměnková. (2024). Arabica: A Python package for exploratory analysis of text data. Journal of Open Source Software, 9(97), 6186. https://doi.org/10.21105/joss.06186.

Register Now to Continue Reading

Unlock Towards Data Science with a Free Account

All articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more. Register for freeSign in to your account


Written By

Petr Koráb

See all from Petr Koráb Animated Word CloudData SciencePythonText MiningWord Cloud Share This Article

Towards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program. Write for TDS

Related Articles

Plotly Front to Back: Bar Charts & Line Charts

Machine Learning Let's get the basics covered. Source code included. Dario Radečić March 26, 20206 min read

Transitioning from Pre-Health to a Career in Data Science/Tech

Data Science Tips/Resources for making the career change in your Undergraduate After spending two years as a... Ram Vegiraju June 2, 20216 min read

Dummy Regressor, Explained: A Visual Guide with Code Examples for Beginners

Machine Learning Naively choosing the best number for all of your prediction Samy Baladram September 25, 20247 min read

Colab Pro: Is it Worth the Money?

Artificial Intelligence How much difference does $10 make? We did the tests. You do the reading. Dario Radečić May 20, 20205 min read

The Power of XML: Simplifying Data Exchange and Storage

Data Science Learning the basics of XML and how to deal with it in Python Niklas Lang August 20, 20225 min read

A Case for Intuition in Data Science

Machine Learning How intuition can help make us better data scientists Brandon Cosley August 16, 20215 min read

Machine Learning and Charity Donations: A Case Study

Machine Learning An in-depth approach on how Yemego NGO uses machine learning techniques to improve donations Jindu Kwentua August 13, 20218 min read

A complete word processing with Python

Data Science Reading pdf file, utilizing regular expressions, exporting to Excel and Word document, and converting it back to pdf format Himalaya Bir Shrestha January 25, 202310 min read

Interview with Apache Pig: Theory and Practical Guide

Machine Learning In this exclusive interview, Apache Pig spoke about his role in the Hadoop ecosystem and elaborated on his use cases and his differences... Meraldo Antonio September 24, 201915 min read

Your home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals. Subscribe to Our NewsletterWrite For TDS•About•Advertise•Privacy Policy•Terms of Use © Insight Media Group, LLC 2026•The New Stack•roadmap.sh•Creator Network

Recommended Articles

Close