TensorTonic
Problems
Novelty Score
Recommender Systems
Medium

Novelty measures how uncommon the recommended items are. An item seen by fewer users carries more self-information and therefore receives a higher novelty value.

novelty⁡=1∣R∣∑i∈R−log⁡2(ciN)\operatorname{novelty} = \frac{1}{|R|}\sum_{i \in R}-\log_2\left(\frac{c_i}{N}\right)novelty=∣R∣1​i∈R∑​−log2​(Nci​​)

Here, R is recommendations, c_i is item_counts[i], and N is n_users. Return the average novelty of the recommended items. Return 0.0 when recommendations is empty.

Loading visualization...

Examples

Input: recommendations = [0, 1], item_counts = [100, 100], n_users = 100

Output: 0.0

Explanation: Both items were seen by every user, so each has zero self-information.

Input: recommendations = [0, 1], item_counts = [1, 1], n_users = 100

Output: 6.6439

Hint 1

Use -math.log2(item_counts[item] / n_users) for one item.

Hint 2

Divide the accumulated novelty by len(recommendations).

Requirements

  • Compute each recommended item popularity as its count divided by n_users.
  • Use the base-2 logarithm for self-information.
  • Average the item novelty values.
  • Return 0.0 for an empty recommendation list.

Constraints

  • recommendations contains valid indices into item_counts.
  • Every recommended item has a positive count.
  • n_users is positive.
  • Time limit: 300 ms.
Try Similar Problems
Implement Precision and Recall at K in PythonEasyTop-K RecommendationsEasyCatalog CoverageEasyHit Rate at KEasyPopularity RankingEasyAdjusted Cosine SimilarityMediumMean Rating ImputationMediumNDCG (Normalized Discounted Cumulative Gain)MediumItem-Based CF PredictionMediumUser-Based CF PredictionMediumRating NormalizationEasyBaseline PredictorHard
Scratchpad

Accepts: array

Accepts: array

Accepts: number

You must run your code first.
Novelty Score

Novelty Score

Recommender Systems
Medium

Novelty measures how uncommon the recommended items are. An item seen by fewer users carries more self-information and therefore receives a higher novelty value.

novelty⁡=1∣R∣∑i∈R−log⁡2(ciN)\operatorname{novelty} = \frac{1}{|R|}\sum_{i \in R}-\log_2\left(\frac{c_i}{N}\right)novelty=∣R∣1​i∈R∑​−log2​(Nci​​)

Here, R is recommendations, c_i is item_counts[i], and N is n_users. Return the average novelty of the recommended items. Return 0.0 when recommendations is empty.

Loading visualization...

Examples

Input: recommendations = [0, 1], item_counts = [100, 100], n_users = 100

Output: 0.0

Explanation: Both items were seen by every user, so each has zero self-information.

Input: recommendations = [0, 1], item_counts = [1, 1], n_users = 100

Output: 6.6439

Hint 1

Use -math.log2(item_counts[item] / n_users) for one item.

Hint 2

Divide the accumulated novelty by len(recommendations).

Requirements

  • Compute each recommended item popularity as its count divided by n_users.
  • Use the base-2 logarithm for self-information.
  • Average the item novelty values.
  • Return 0.0 for an empty recommendation list.

Constraints

  • recommendations contains valid indices into item_counts.
  • Every recommended item has a positive count.
  • n_users is positive.
  • Time limit: 300 ms.
Try Similar Problems
Implement Precision and Recall at K in PythonEasyTop-K RecommendationsEasyCatalog CoverageEasyHit Rate at KEasyPopularity RankingEasyAdjusted Cosine SimilarityMediumMean Rating ImputationMediumNDCG (Normalized Discounted Cumulative Gain)MediumItem-Based CF PredictionMediumUser-Based CF PredictionMediumRating NormalizationEasyBaseline PredictorHard
Scratchpad

Accepts: array

Accepts: array

Accepts: number

You must run your code first.
Problems
Loading...
1 / 1