From 1c640cb8ad79510f13d999bb8a49600762dc388e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 26 Jul 2021 18:54:24 +0000 Subject: [PATCH 1/6] remove special characters --- .../als_movielens_diversity_metrics.ipynb | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb index a8c1c7b60a..b1c24af9ba 100644 --- a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb +++ b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb @@ -19,12 +19,10 @@ "In this notebook, we demonstrate how to evaluate a recommender using metrics other than commonly used rating/ranking metrics.\n", "\n", "Such metrics include:\n", - "- Coverage - The proportion of items that can be recommended. It includes two metrics:\n", + "- Coverage - We use following two metrics defined from \\[Shani and Gunawardana\\]:\n", " \n", " - (1) catalog_coverage, which measures the proportion of items that get recommended from the item catalog; \n", - " - (2) distributional_coverage, which measures how unequally different items are recommended in the recommendations to all users.\n", - " \n", - " We use definitions of these metrics from \\[Shani and Gunawardana\\].\n", + " - (2) distributional_coverage, which measures how equally different items are recommended in the recommendations to all users.\n", "\n", "- Novelty - A more novel item indicates it is less popular, i.e. it gets recommended less frequently.\n", "We use the definition of novelty from \\[Castells et al.\\]\n", @@ -86,7 +84,7 @@ "$$\n", "where $M$ is the set of users and $N_r(u)$ the set of recommendations for user $u$. Finally, diversity is defined as\n", "$$\n", - "\\textrm{diversity} = 1 - \\textrm{IL} ~.\n", + "\\textrm{diversity} = 1 - \\textrm{IL}\n", "$$\n" ], "cell_type": "markdown", @@ -103,11 +101,11 @@ "$$\n", "where $M_t (i)$ is the set of users who have interacted with item $i$ in the historical data. The novelty of an item is then defined as\n", "$$\n", - "\\textrm{novelty}(i) = -\\log_2⁡ p(i) \n", + "\\textrm{novelty}(i) = -\\log_2 ⁡ p(i) \n", "$$\n", "and the novelty of the recommendations across all users is defined as\n", "$$\n", - "\\textrm{novelty} = \\sum_{i \\in N_r} \\frac{|M_r (i)|}{|\\textrm{reco_df}|} \\textrm{novelty}(i) ~.\n", + "\\textrm{novelty} = \\sum_{i \\in N_r} \\frac{|M_r (i)|}{|\\textrm{reco_df}|} \\textrm{novelty}(i)\n", "$$\n" ], "cell_type": "markdown", @@ -126,7 +124,7 @@ "serendipity is defined as\n", "$$\n", "\\textrm{serendipity} = \\frac{1}{|M|} \\sum_{u \\in M_r}\n", - "\\frac{1}{|N_r (u)|} \\sum_{i \\in N_r (u)} \\big(1 - \\textrm{expectedness}(i|u) \\big) \\, \\textrm{relevance}(i) ~.\n", + "\\frac{1}{|N_r (u)|} \\sum_{i \\in N_r (u)} \\big(1 - \\textrm{expectedness}(i|u) \\big) \\, \\textrm{relevance}(i)\n", "$$\n" ], "cell_type": "markdown", @@ -165,12 +163,12 @@ "from pyspark.sql.types import StructType, StructField\n", "from pyspark.sql.types import StringType, FloatType, IntegerType, LongType\n", "\n", - "from recommenders.utils.timer import Timer\n", - "from recommenders.datasets import movielens\n", - "from recommenders.utils.notebook_utils import is_jupyter\n", - "from recommenders.datasets.spark_splitters import spark_random_split\n", - "from recommenders.evaluation.spark_evaluation import SparkRatingEvaluation, SparkRankingEvaluation, SparkDiversityEvaluation\n", - "from recommenders.utils.spark_utils import start_or_get_spark\n", + "from reco_utils.utils.timer import Timer\n", + "from reco_utils.datasets import movielens\n", + "from reco_utils.utils.notebook_utils import is_jupyter\n", + "from reco_utils.datasets.spark_splitters import spark_random_split\n", + "from reco_utils.evaluation.spark_evaluation import SparkRatingEvaluation, SparkRankingEvaluation, SparkDiversityEvaluation\n", + "from reco_utils.utils.spark_utils import start_or_get_spark\n", "\n", "from pyspark.sql.window import Window\n", "\n", From 1266cbba200bc456d58093beb3f1b50dc40713c7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 26 Jul 2021 19:01:27 +0000 Subject: [PATCH 2/6] fix formula --- examples/03_evaluate/als_movielens_diversity_metrics.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb index b1c24af9ba..a94618300f 100644 --- a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb +++ b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb @@ -19,7 +19,7 @@ "In this notebook, we demonstrate how to evaluate a recommender using metrics other than commonly used rating/ranking metrics.\n", "\n", "Such metrics include:\n", - "- Coverage - We use following two metrics defined from \\[Shani and Gunawardana\\]:\n", + "- Coverage - We use following two metrics defined by \\[Shani and Gunawardana\\]:\n", " \n", " - (1) catalog_coverage, which measures the proportion of items that get recommended from the item catalog; \n", " - (2) distributional_coverage, which measures how equally different items are recommended in the recommendations to all users.\n", @@ -99,7 +99,9 @@ "$$\n", "p(i) = \\frac{|M_t (i)|} {|\\textrm{train_df}|}\n", "$$\n", - "where $M_t (i)$ is the set of users who have interacted with item $i$ in the historical data. The novelty of an item is then defined as\n", + "where $M_t (i)$ is the set of users who have interacted with item $i$ in the historical data. \n", + "$$\n", + "The novelty of an item is then defined as\n", "$$\n", "\\textrm{novelty}(i) = -\\log_2 ⁡ p(i) \n", "$$\n", From 81cdff92407217f7a776969b638ad8c8a62a0b38 Mon Sep 17 00:00:00 2001 From: YanZhangADS Date: Mon, 26 Jul 2021 19:05:05 +0000 Subject: [PATCH 3/6] fix formula --- examples/03_evaluate/als_movielens_diversity_metrics.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb index a94618300f..905e1a94cb 100644 --- a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb +++ b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb @@ -100,7 +100,7 @@ "p(i) = \\frac{|M_t (i)|} {|\\textrm{train_df}|}\n", "$$\n", "where $M_t (i)$ is the set of users who have interacted with item $i$ in the historical data. \n", - "$$\n", + "\n", "The novelty of an item is then defined as\n", "$$\n", "\\textrm{novelty}(i) = -\\log_2 ⁡ p(i) \n", From 04ba88bfae6535893aac319726249c39772b5ba0 Mon Sep 17 00:00:00 2001 From: YanZhangADS Date: Mon, 26 Jul 2021 19:06:45 +0000 Subject: [PATCH 4/6] fix formula --- examples/03_evaluate/als_movielens_diversity_metrics.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb index 905e1a94cb..d03ec1507e 100644 --- a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb +++ b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb @@ -103,7 +103,7 @@ "\n", "The novelty of an item is then defined as\n", "$$\n", - "\\textrm{novelty}(i) = -\\log_2 ⁡ p(i) \n", + "\\textrm{novelty}(i) = -\\log_2 ⁡ p(i)\n", "$$\n", "and the novelty of the recommendations across all users is defined as\n", "$$\n", From 8266d1277e172b25ac35290fc46d123b87af7c8b Mon Sep 17 00:00:00 2001 From: YanZhangADS Date: Mon, 26 Jul 2021 19:09:51 +0000 Subject: [PATCH 5/6] fix formula --- examples/03_evaluate/als_movielens_diversity_metrics.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb index d03ec1507e..e6635ea518 100644 --- a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb +++ b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb @@ -103,7 +103,7 @@ "\n", "The novelty of an item is then defined as\n", "$$\n", - "\\textrm{novelty}(i) = -\\log_2 ⁡ p(i)\n", + "\\textrm{novelty}(i) = -\\log_2 p(i)\n", "$$\n", "and the novelty of the recommendations across all users is defined as\n", "$$\n", From 9b6a1375a1be9dcc131bab22816bc0aaff51b9d1 Mon Sep 17 00:00:00 2001 From: YanZhangADS Date: Tue, 27 Jul 2021 10:52:29 +0000 Subject: [PATCH 6/6] fix package import --- .../als_movielens_diversity_metrics.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb index e6635ea518..d9af89380e 100644 --- a/examples/03_evaluate/als_movielens_diversity_metrics.ipynb +++ b/examples/03_evaluate/als_movielens_diversity_metrics.ipynb @@ -165,12 +165,12 @@ "from pyspark.sql.types import StructType, StructField\n", "from pyspark.sql.types import StringType, FloatType, IntegerType, LongType\n", "\n", - "from reco_utils.utils.timer import Timer\n", - "from reco_utils.datasets import movielens\n", - "from reco_utils.utils.notebook_utils import is_jupyter\n", - "from reco_utils.datasets.spark_splitters import spark_random_split\n", - "from reco_utils.evaluation.spark_evaluation import SparkRatingEvaluation, SparkRankingEvaluation, SparkDiversityEvaluation\n", - "from reco_utils.utils.spark_utils import start_or_get_spark\n", + "from recommenders.utils.timer import Timer\n", + "from recommenders.datasets import movielens\n", + "from recommenders.utils.notebook_utils import is_jupyter\n", + "from recommenders.datasets.spark_splitters import spark_random_split\n", + "from recommenders.evaluation.spark_evaluation import SparkRatingEvaluation, SparkRankingEvaluation, SparkDiversityEvaluation\n", + "from recommenders.utils.spark_utils import start_or_get_spark\n", "\n", "from pyspark.sql.window import Window\n", "\n",