Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: TF-IDF | Basic Text Models
Introduction to NLP

Pyyhkäise näyttääksesi valikon

book
Challenge: TF-IDF

Tehtävä

Swipe to start coding

You have a text corpus stored in corpus variable. Your task is to display the vector for the 'medical' unigram in a TF-IDF model with unigrams, bigrams, and trigrams. To do this:

  1. Import the TfidfVectorizer class to create a TF-IDF model.
  2. Instantiate the TfidfVectorizer class as tfidf_vectorizer and configure it to include unigrams, bigrams, and trigrams.
  3. Use the appropriate method of tfidf_vectorizer to generate a TF-IDF matrix from the 'Document' column in the corpus and store the result in tfidf_matrix.
  4. Convert tfidf_matrix to a dense array and create a DataFrame from it, setting the unique features (terms) as its columns. Store the result in the tfidf_matrix_df variable.
  5. Display the vector for 'medical' as an array.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 8
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

Awesome!

Completion rate improved to 3.45

book
Challenge: TF-IDF

Tehtävä

Swipe to start coding

You have a text corpus stored in corpus variable. Your task is to display the vector for the 'medical' unigram in a TF-IDF model with unigrams, bigrams, and trigrams. To do this:

  1. Import the TfidfVectorizer class to create a TF-IDF model.
  2. Instantiate the TfidfVectorizer class as tfidf_vectorizer and configure it to include unigrams, bigrams, and trigrams.
  3. Use the appropriate method of tfidf_vectorizer to generate a TF-IDF matrix from the 'Document' column in the corpus and store the result in tfidf_matrix.
  4. Convert tfidf_matrix to a dense array and create a DataFrame from it, setting the unique features (terms) as its columns. Store the result in the tfidf_matrix_df variable.
  5. Display the vector for 'medical' as an array.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

close

Awesome!

Completion rate improved to 3.45

Pyyhkäise näyttääksesi valikon

some-alt