Course Content
Introduction to NLP
Introduction to NLP
Challenge: Creating a Bag of Words
Swipe to show code editor
Your task is to display the vector for the 'graphic design' bigram in a BoW model:
-
Import the
CountVectorizer
class to create a BoW model. -
Instantiate the
CountVectorizer
class ascount_vectorizer
, configuring it for a frequency-based model that includes both unigrams and bigrams. -
Utilize the appropriate method of
count_vectorizer
to generate a BoW matrix from the'Document'
column in thecorpus
. -
Convert
bow_matrix
to a dense array and create aDataFrame
from it, setting the unique features (unigrams and bigrams) as its columns. Assign this to the variablebow_df
. -
Display the vector for 'graphic design' as an array, rather than as a pandas
Series
.
Thanks for your feedback!
Challenge: Creating a Bag of Words
Swipe to show code editor
Your task is to display the vector for the 'graphic design' bigram in a BoW model:
-
Import the
CountVectorizer
class to create a BoW model. -
Instantiate the
CountVectorizer
class ascount_vectorizer
, configuring it for a frequency-based model that includes both unigrams and bigrams. -
Utilize the appropriate method of
count_vectorizer
to generate a BoW matrix from the'Document'
column in thecorpus
. -
Convert
bow_matrix
to a dense array and create aDataFrame
from it, setting the unique features (unigrams and bigrams) as its columns. Assign this to the variablebow_df
. -
Display the vector for 'graphic design' as an array, rather than as a pandas
Series
.
Thanks for your feedback!
Challenge: Creating a Bag of Words
Swipe to show code editor
Your task is to display the vector for the 'graphic design' bigram in a BoW model:
-
Import the
CountVectorizer
class to create a BoW model. -
Instantiate the
CountVectorizer
class ascount_vectorizer
, configuring it for a frequency-based model that includes both unigrams and bigrams. -
Utilize the appropriate method of
count_vectorizer
to generate a BoW matrix from the'Document'
column in thecorpus
. -
Convert
bow_matrix
to a dense array and create aDataFrame
from it, setting the unique features (unigrams and bigrams) as its columns. Assign this to the variablebow_df
. -
Display the vector for 'graphic design' as an array, rather than as a pandas
Series
.
Thanks for your feedback!
Swipe to show code editor
Your task is to display the vector for the 'graphic design' bigram in a BoW model:
-
Import the
CountVectorizer
class to create a BoW model. -
Instantiate the
CountVectorizer
class ascount_vectorizer
, configuring it for a frequency-based model that includes both unigrams and bigrams. -
Utilize the appropriate method of
count_vectorizer
to generate a BoW matrix from the'Document'
column in thecorpus
. -
Convert
bow_matrix
to a dense array and create aDataFrame
from it, setting the unique features (unigrams and bigrams) as its columns. Assign this to the variablebow_df
. -
Display the vector for 'graphic design' as an array, rather than as a pandas
Series
.