Click4Ai

528.

Medium

In A/B testing, we want to compare the performance of two different versions of a recommendation system. We have two versions of a recommendation system, A and B. Version A uses a simple collaborative filtering approach, while version B uses a matrix factorization approach. We have the following user-item interaction data:

Example:

We have 10 users and 5 items. The interaction data is represented as a 2D array, where the entry at row i and column j represents the rating given by user i to item j. For example, the entry at row 0 and column 1 represents the rating given by user 0 to item 1.

Constraints:

  • The interaction data is represented as a 2D array of shape (10, 5).
  • The ratings are integers between 0 and 5.
  • Write a function to calculate the average rating for each version of the recommendation system.

    Test Cases

    Test Case 1
    Input: [[1,2,3,4,5],[4,5,6,7,8],[9,10,11,12,13],[14,15,16,17,18],[19,20,21,22,23],[24,25,26,27,28],[29,30,31,32,33],[34,35,36,37,38],[39,40,41,42,43],[44,45,46,47,48]]
    Expected: [[2. 2.5 3. 3.5 4. ] [4. 4.5 5. 5.5 6. ] [6. 6.5 7. 7.5 8. ] [8. 8.5 9. 9.5 10. ] [10. 11. 12. 13. 14. ] [14. 15. 16. 17. 18. ] [18. 19. 20. 21. 22. ] [22. 23. 24. 25. 26. ] [26. 27. 28. 29. 30. ] [30. 31. 32. 33. 34. ]]
    Test Case 2
    Input: [[1,2,3,4,5],[4,5,6,7,8],[9,10,11,12,13],[14,15,16,17,18],[19,20,21,22,23],[24,25,26,27,28],[29,30,31,32,33],[34,35,36,37,38],[39,40,41,42,43],[44,45,46,47,48]]
    Expected: [[2. 2.5 3. 3.5 4. ] [4. 4.5 5. 5.5 6. ] [6. 6.5 7. 7.5 8. ] [8. 8.5 9. 9.5 10. ] [10. 11. 12. 13. 14. ] [14. 15. 16. 17. 18. ] [18. 19. 20. 21. 22. ] [22. 23. 24. 25. 26. ] [26. 27. 28. 29. 30. ] [30. 31. 32. 33. 34. ]]
    + 3 hidden test cases