Challenge: Bag of Words
Compito
Swipe to start coding
You have a text corpus stored in corpus
variable. Your task is to display the vector for the 'graphic design' bigram in a BoW model. To do this:
- 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. - Use the appropriate method of
count_vectorizer
to generate a BoW matrix from the'Document'
column in thecorpus
and store the result inbow_matrix
. - Convert
bow_matrix
to a dense array and create aDataFrame
from it, setting the unique features (unigrams and bigrams) as its columns. Store the result in thebow_df
variable. - Display the vector for
'graphic design'
bigram as an array.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 3. Capitolo 5
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Suggested prompts:
Riassuma questo capitolo
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 3.45
Challenge: Bag of Words
Scorri per mostrare il menu
Compito
Swipe to start coding
You have a text corpus stored in corpus
variable. Your task is to display the vector for the 'graphic design' bigram in a BoW model. To do this:
- 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. - Use the appropriate method of
count_vectorizer
to generate a BoW matrix from the'Document'
column in thecorpus
and store the result inbow_matrix
. - Convert
bow_matrix
to a dense array and create aDataFrame
from it, setting the unique features (unigrams and bigrams) as its columns. Store the result in thebow_df
variable. - Display the vector for
'graphic design'
bigram as an array.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Awesome!
Completion rate improved to 3.45Sezione 3. Capitolo 5
single