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
      50 of 102

      Grade a spam filter

      A spam filter is graded on two numbers. Precision: of the emails it flagged, the share that really are spam. Recall: of all the spam, the share it flagged. Write filter_score(precision, recall): one number for how good the filter is, from 0 (useless) to 1 (perfect).

      A filter sorts 40 emails, 15 of them spam, moving the ones it suspects into the spam folder. Precision grades the folder, recall grades how much of the spam it caught. Your function turns the two into one grade.

      precision 0.9, recall 0.6spamreal mailinboxspam folderthe filterspam folder: 9 of 10 are spam → precision 0.9all the spam: 9 of 15 reached the folder → recall 0.6grade0%50%100%?
      Your functionfilter_score(precision, recall)
      precisionshare of flagged emails that really are spame.g. 1
      recallshare of all spam that got flaggede.g. 1
      returnsone score from 0 (useless) to 1 (perfect)
      solution.pyLoading Python
      Sign in for an AI hint
      ← Better than guessing the average?Pick the sick one →