コード例 #1
0
 def test_recommend2(self):
     train = list2dataframe_time(raw_data1)
     rank = RecommendUserSimilarityTime(train, t0=10)
     self.assertEqual(rank["user1"][0], "item4")
     train1 = list2dataframe_time(raw_data)
     rank1 = RecommendUserSimilarityTime(train1, N=4, t0=10)
     self.assertEqual(rank1[1][0], 8)
コード例 #2
0
 def test_recommend1(self):
     train = list2dataframe_time(raw_data1)
     result = RecommendItemSimilarityTime(train, k=3, N=5, t0=10)
     self.assertEqual(result["user1"][0], "item3")
     train1 = list2dataframe_time(raw_data)
     rank1 = RecommendItemSimilarityTime(train1, N=5, t0=10)
     self.assertAlmostEqual(rank1[1][1], 6)
コード例 #3
0
 def test_rank_user(self):
     train = list2dataframe_time(raw_data1)
     rank = GetRankUserSimilarityTime(train, t0=10)
     self.assertAlmostEqual(rank["user1"]["item4"], 0.01944039)
     train1 = list2dataframe_time(raw_data)
     rank1 = GetRankUserSimilarityTime(train1, k=4, t0=10)
     self.assertAlmostEqual(rank1[1][8], 0.20097049)
コード例 #4
0
 def test_rank_item(self):
     train = list2dataframe_time(raw_data1)
     rank = GetRankItemSimilarityTime(train, k=3, t0=10)
     self.assertAlmostEqual(rank["user1"]["item4"], 0.02142747)
     train1 = list2dataframe_time(raw_data)
     rank1 = GetRankItemSimilarityTime(train1, t0=10)
     self.assertAlmostEqual(rank1[1][7], 0)
コード例 #5
0
 def test_usersimilarity(self):
     train1 = list2dataframe_time(raw_data1)
     dataframe1 = UserSimilarityTime(train1, 0.6)
     self.assertAlmostEqual(dataframe1["user2"]["user3"], 0.20833333)
     self.assertAlmostEqual(dataframe1["user1"]["user3"], 0.18556740)
     train2 = list2dataframe_time(raw_data)
     dataframe2 = UserSimilarityTime(train2, 0.6)
     self.assertAlmostEqual(dataframe2[1][2], 0.14186752)
     self.assertAlmostEqual(dataframe2[4][6], 0.25515518)
コード例 #6
0
 def test_itemsimilarity(self):
     train = list2dataframe_time(raw_data)
     print(train)
     dataframe1 = ItemSimilarityTime(train, 0.6)
     self.assertEqual(dataframe1[1][1], 0)
     self.assertEqual(dataframe1[4][3], 0.3125)
     train2 = list2dataframe_time(raw_data1)
     dataframe2 = ItemSimilarityTime(train2, 0.6)
     self.assertAlmostEqual(dataframe2["item5"]["item2"], 0.17677669)
     self.assertAlmostEqual(dataframe2["item4"]["item3"], 0.44194173)
コード例 #7
0
 def test_list2dataframe_time(self):
     dataframe1 = list2dataframe_time(raw_data)
     self.assertEqual(dataframe1[1].values.tolist()[0:3], [0, 1, 4])
     dataframe2 = list2dataframe_time(raw_data1)
     self.assertEqual(dataframe2["user2"]["item5"], 5)
コード例 #8
0
 def test_most_hot_month(self):
     train = list2dataframe_time(raw_data1)
     result = RecommendMostHotMonth(train, date_now='2018-05-11')
     self.assertEqual(result[0], 'item2')