From the course: Natural Language Processing in Python
Unlock this course with a free trial
Join today to access over 26,400 courses taught by industry experts.
Solution: CountVectorizer - Python Tutorial
From the course: Natural Language Processing in Python
Solution: CountVectorizer
For this assignment, our first step is to vectorize the cleaned and normalized text. If you remember from the last assignment, we cleaned and normalized a column of text and we saved it in a data frame called df. So down here, let me add a few more cells. And let's first take a look at our clean text. You can see here we have this description clean column. And it's been cleaned and normalized using pandas and spaCy. So now we're ready to vectorize this column. I'm going to start by changing this to a two so I can still see this text column as I'm coding. And the first thing we have to do is import count vectorizer. I'm going to go to scikit-learn and then specifically the feature extraction section focused on text data. And here I'm going to import count vectorizer with a capital C and a capital V. Okay, now next we need to instantiate a new count vectorizer object. I'm going to say count vectorizer once again, and then put parentheses after, and I'm going to call that CV. And now…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Section introduction59s
-
(Locked)
NLP pipeline2m 43s
-
(Locked)
Text preprocessing overview2m 35s
-
(Locked)
Assignment: Create a new environment1m 28s
-
(Locked)
Solution: Create a new environment3m 20s
-
(Locked)
Text preprocessing with pandas4m 19s
-
(Locked)
Demo: Text preprocessing setup6m 4s
-
(Locked)
Demo: Text preprocessing with pandas8m 14s
-
(Locked)
Pro tip: Create a function4m 25s
-
(Locked)
Assignment: Text preprocessing with pandas3m 22s
-
(Locked)
Solution: Text preprocessing with pandas8m 12s
-
(Locked)
Text preprocessing with spaCy1m 38s
-
(Locked)
Tokenization2m 5s
-
(Locked)
Lemmatization2m 42s
-
(Locked)
Stop words1m 17s
-
(Locked)
Parts of speech tagging2m 1s
-
(Locked)
Demo: Tokens, lemmas, and stop words8m
-
(Locked)
Pro tip: Use the apply method5m 59s
-
(Locked)
Demo: Parts of speech tagging9m 27s
-
(Locked)
Demo: Create an NLP pipeline6m 15s
-
(Locked)
Assignment: Text preprocessing with spaCy41s
-
(Locked)
Solution: Text preprocessing with spaCy7m 57s
-
(Locked)
Vectorization4m 45s
-
(Locked)
CountVectorizer in Python8m 4s
-
(Locked)
Demo: CountVectorizer5m 48s
-
(Locked)
Demo: CountVectorizer parameters5m 5s
-
(Locked)
Pro tip: Exploratory data analysis2m 13s
-
(Locked)
Assignment: CountVectorizer1m 16s
-
(Locked)
Solution: CountVectorizer7m 36s
-
(Locked)
Term frequency–inverse document frequency (TF-IDF)6m 30s
-
(Locked)
TF-IDF vectorizer in Python5m 8s
-
(Locked)
Demo: TF-IDF vectorizer4m 52s
-
(Locked)
Assignment: TF-IDF vectorizer1m 7s
-
(Locked)
Solution: TF-IDF vectorizer7m 38s
-
(Locked)
Key takeaways4m 13s
-
(Locked)
-
-
-
-
-