Nobody scrolls past the first handful of recommendations, so recommender systems are judged on the top k and nothing else.
k items you showed, what fraction were relevant?Task: write precision_recall_at_k(recommended, relevant, k) returning [precision, recall], both rounded to 4 decimal places.
recommended is ordered best-first; only its first k entries count.k, use what's there — precision divides by how many you actually showed.0.0 for either metric when its denominator would be zero.relevant is a set of items, unordered.The two pull against each other. Recommending everything makes recall perfect and precision worthless; recommending one sure thing does the reverse. Fixing
kis what forces the system to commit.