Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      22 of 102

      Which words matter?

      You’re building search over a library of documents. Some words say what a document is about; others are just glue. Write importance(times_in_doc, docs_with_word, total_docs): how important one word is to one document. times_in_doc is how often this document uses the word, docs_with_word how many documents in the library use it at all, and total_docs how many documents there are.

      An article about plants, in a library of 100 articles. Three of its words: how often this article says each one, and which articles in the library use it at all. Your function scores how important each word is to this article.

      wordtimes in this articleimportant?the?leaf?chlorophyll?the library: 100 articlesthis articleHow important is each word to this article?click a word to light the articles that use it
      Your functionimportance(times_in_doc, docs_with_word, total_docs)
      times_in_dochow often this document uses the worde.g. 5
      docs_with_wordhow many documents in the library use ite.g. 100
      total_docshow many documents the library hase.g. 100
      returnshow important the word is to this document
      solution.pyLoading Python
      Sign in for an AI hint
      ← Colors into numbersThe tenth mention →