From 9448063ab21ed7e0034c0ef8fa52f370f5416455 Mon Sep 17 00:00:00 2001 From: jiangzhonglian Date: Mon, 5 Jun 2017 11:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ml-1m/README | 0 .../ml-1m/movies.dat | 0 .../ml-1m/ratings.dat | 0 .../ml-1m/users.dat | 0 .../itemcf.py | 2 +- .../test_evaluation_model.py | 0 .../test_graph-based.py | 0 .../test_lfm.py | 7 ++++--- .../test_基于物品.py | 0 .../test_基于用户.py | 0 .../usercf.py | 2 +- 11 files changed, 6 insertions(+), 5 deletions(-) rename input/{16.RecommendedSystem => 16.RecommenderSystems}/ml-1m/README (100%) rename input/{16.RecommendedSystem => 16.RecommenderSystems}/ml-1m/movies.dat (100%) rename input/{16.RecommendedSystem => 16.RecommenderSystems}/ml-1m/ratings.dat (100%) rename input/{16.RecommendedSystem => 16.RecommenderSystems}/ml-1m/users.dat (100%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/itemcf.py (99%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/test_evaluation_model.py (100%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/test_graph-based.py (100%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/test_lfm.py (95%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/test_基于物品.py (100%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/test_基于用户.py (100%) rename src/python/{16.RecommendedSystem => 16.RecommenderSystems}/usercf.py (99%) diff --git a/input/16.RecommendedSystem/ml-1m/README b/input/16.RecommenderSystems/ml-1m/README similarity index 100% rename from input/16.RecommendedSystem/ml-1m/README rename to input/16.RecommenderSystems/ml-1m/README diff --git a/input/16.RecommendedSystem/ml-1m/movies.dat b/input/16.RecommenderSystems/ml-1m/movies.dat similarity index 100% rename from input/16.RecommendedSystem/ml-1m/movies.dat rename to input/16.RecommenderSystems/ml-1m/movies.dat diff --git a/input/16.RecommendedSystem/ml-1m/ratings.dat b/input/16.RecommenderSystems/ml-1m/ratings.dat similarity index 100% rename from input/16.RecommendedSystem/ml-1m/ratings.dat rename to input/16.RecommenderSystems/ml-1m/ratings.dat diff --git a/input/16.RecommendedSystem/ml-1m/users.dat b/input/16.RecommenderSystems/ml-1m/users.dat similarity index 100% rename from input/16.RecommendedSystem/ml-1m/users.dat rename to input/16.RecommenderSystems/ml-1m/users.dat diff --git a/src/python/16.RecommendedSystem/itemcf.py b/src/python/16.RecommenderSystems/itemcf.py similarity index 99% rename from src/python/16.RecommendedSystem/itemcf.py rename to src/python/16.RecommenderSystems/itemcf.py index 849b7a69..1ba67b95 100644 --- a/src/python/16.RecommendedSystem/itemcf.py +++ b/src/python/16.RecommenderSystems/itemcf.py @@ -200,7 +200,7 @@ class ItemBasedCF(): if __name__ == '__main__': - ratingfile = 'input/16.RecommendedSystem/ml-1m/ratings.dat' + ratingfile = 'input/16.RecommenderSystems/ml-1m/ratings.dat' # 创建ItemCF对象 itemcf = ItemBasedCF() diff --git a/src/python/16.RecommendedSystem/test_evaluation_model.py b/src/python/16.RecommenderSystems/test_evaluation_model.py similarity index 100% rename from src/python/16.RecommendedSystem/test_evaluation_model.py rename to src/python/16.RecommenderSystems/test_evaluation_model.py diff --git a/src/python/16.RecommendedSystem/test_graph-based.py b/src/python/16.RecommenderSystems/test_graph-based.py similarity index 100% rename from src/python/16.RecommendedSystem/test_graph-based.py rename to src/python/16.RecommenderSystems/test_graph-based.py diff --git a/src/python/16.RecommendedSystem/test_lfm.py b/src/python/16.RecommenderSystems/test_lfm.py similarity index 95% rename from src/python/16.RecommendedSystem/test_lfm.py rename to src/python/16.RecommenderSystems/test_lfm.py index 816a34a5..13a7abff 100644 --- a/src/python/16.RecommendedSystem/test_lfm.py +++ b/src/python/16.RecommenderSystems/test_lfm.py @@ -1,17 +1,18 @@ + # 负样本采样过程 def RandomSelectNegativeSample(self, items): ret = dict() for i in items.keys(): ret[i] = 1 - + n = 0 for i in range(0, len(items) * 3): item = items_pool[random.randint(0, len(items_pool) - 1)] if item in ret: continue ret[item] = 0 - n + = 1 + n += 1 if n > len(items): break return ret @@ -19,7 +20,7 @@ def RandomSelectNegativeSample(self, items): def LatentFactorModel(user_items, F, N, alpha, lambda): [P, Q] = InitModel(user_items, F) - for step in range(0,N): + for step in range(0, N): for user, items in user_items.items(): samples = RandSelectNegativeSamples(items) for item, rui in samples.items(): diff --git a/src/python/16.RecommendedSystem/test_基于物品.py b/src/python/16.RecommenderSystems/test_基于物品.py similarity index 100% rename from src/python/16.RecommendedSystem/test_基于物品.py rename to src/python/16.RecommenderSystems/test_基于物品.py diff --git a/src/python/16.RecommendedSystem/test_基于用户.py b/src/python/16.RecommenderSystems/test_基于用户.py similarity index 100% rename from src/python/16.RecommendedSystem/test_基于用户.py rename to src/python/16.RecommenderSystems/test_基于用户.py diff --git a/src/python/16.RecommendedSystem/usercf.py b/src/python/16.RecommenderSystems/usercf.py similarity index 99% rename from src/python/16.RecommendedSystem/usercf.py rename to src/python/16.RecommenderSystems/usercf.py index 0f780431..fc528292 100644 --- a/src/python/16.RecommendedSystem/usercf.py +++ b/src/python/16.RecommenderSystems/usercf.py @@ -208,7 +208,7 @@ class UserBasedCF(): if __name__ == '__main__': - ratingfile = 'input/16.RecommendedSystem/ml-1m/ratings.dat' + ratingfile = 'input/16.RecommenderSystems/ml-1m/ratings.dat' # 创建UserCF对象 usercf = UserBasedCF()