Challenge: Creating a Bag of Words
Swipe to start coding
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
.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Resumir este capítulo
Explicar el código en file
Explicar por qué file no resuelve la tarea
Awesome!
Completion rate improved to 4.17
Challenge: Creating a Bag of Words
Desliza para mostrar el menú
Swipe to start coding
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
.
Solución
¡Gracias por tus comentarios!
Awesome!
Completion rate improved to 4.17single