Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Unsupervised Learning Workshop

You're reading from   The Unsupervised Learning Workshop Get started with unsupervised learning algorithms and simplify your unorganized data to help make future predictions

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781800200708
Length 550 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Benjamin Johnston Benjamin Johnston
Author Profile Icon Benjamin Johnston
Benjamin Johnston
Christopher Kruger Christopher Kruger
Author Profile Icon Christopher Kruger
Christopher Kruger
Aaron Jones Aaron Jones
Author Profile Icon Aaron Jones
Aaron Jones
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface
1. Introduction to Clustering 2. Hierarchical Clustering FREE CHAPTER 3. Neighborhood Approaches and DBSCAN 4. Dimensionality Reduction Techniques and PCA 5. Autoencoders 6. t-Distributed Stochastic Neighbor Embedding 7. Topic Modeling 8. Market Basket Analysis 9. Hotspot Analysis Appendix

7. Topic Modeling

Activity 7.01: Loading and Cleaning Twitter Data

Solution:

  1. Import the necessary libraries:
    import warnings
    warnings.filterwarnings('ignore')
    import langdetect 
    import matplotlib.pyplot 
    import nltk
    nltk.download('wordnet')
    nltk.download('stopwords')
    import numpy 
    import pandas 
    import pyLDAvis 
    import pyLDAvis.sklearn 
    import regex 
    import sklearn 
  2. Load the LA Times health Twitter data (latimeshealth.txt) from https://packt.live/2Xje5xF.

    Note

    Pay close attention to the delimiter (it is neither a comma nor a tab) and double-check the header status.

    The code looks as follows:

    path = 'latimeshealth.txt' 
    df = pandas.read_csv(path, sep="|", header=None)
    df.columns = ["id", "datetime", "tweettext"]
  3. Run a quick exploratory analysis to ascertain the data size and structure:
    def dataframe_quick_look(df, nrows):
        print("SHAPE:\n{shape}\n".format(shape...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime