精华内容
下载资源
问答
  • 推荐系统项目实战 强烈推荐按这本书哦,资料很全,也很有逻辑 新的一年,学习新的知识,这里学习了这本书,计划两周学完 数据集 代码 # -*- coding:utf-8 -*- """ Author: Thinkgamer Desc: 代码2-1 ...

    推荐系统项目实战

    在这里插入图片描述

    强烈推荐按这本书哦,资料很全,也很有逻辑
    新的一年,学习新的知识,这里学习了这本书,计划两周学完
    在这里插入图片描述

    1. 数据集 链接:https://pan.baidu.com/s/1MVsdKM2q6cq-mL_I5DOt7A
      提取码:0tqo

    在这里插入图片描述

    1. 代码
    # -*- coding:utf-8 -*-
    
    """
        Author: Thinkgamer
        Desc:
            代码2-1  实例1:搭建你的第一个推荐系统-电影推荐系统
            从中随机选择1000个与用户进行计算
    """
    import os
    import json
    import random
    import math
    
    class FirstRec:
        """
            初始化函数
                filePath: 原始文件路径
                seed:产生随机数的种子
                k:选取的近邻用户个数
                nitems:为每个用户推荐的电影数
        """
        def __init__(self,file_path,seed,k,n_items):
            self.file_path = file_path
            self.users_1000 = self.__select_1000_users()
            self.seed = seed
            self.k = k
            self.n_items = n_items
            self.train,self.test = self._load_and_split_data()
    
        # 获取所有用户并随机选取1000个
        def __select_1000_users(self):
            print("随机选取1000个用户!")
            if os.path.exists("data/train.json") and os.path.exists("data/test.json"):
                return list()
            else:
                users = set()
                # 获取所有用户
                for file in os.listdir(self.file_path):
                    one_path = "{}/{}".format(self.file_path, file)
                    print("{}".format(one_path))
                    with open(one_path, "r") as fp:
                        for line in fp.readlines():
                            if line.strip().endswith(":"):
                                continue
                            userID, _ , _ = line.split(",")
                            users.add(userID)
                # 随机选取1000个
                users_1000 = random.sample(list(users),1000)
                print(users_1000)
                return users_1000
    
        # 加载数据,并拆分为训练集和测试集
        def _load_and_split_data(self):
            train = dict()
            test = dict()
            if os.path.exists("data/train.json") and os.path.exists("data/test.json"):
                print("从文件中加载训练集和测试集")
                train = json.load(open("data/train.json"))
                test = json.load(open("data/test.json"))
                print("从文件中加载数据完成")
            else:
                # 设置产生随机数的种子,保证每次实验产生的随机结果一致
                random.seed(self.seed)
                for file in os.listdir(self.file_path):
                    one_path = "{}/{}".format(self.file_path, file)
                    print("{}".format(one_path))
                    with open(one_path,"r") as fp:
                        movieID = fp.readline().split(":")[0]
                        for line in fp.readlines():
                            if line.endswith(":"):
                                continue
                            userID, rate, _ = line.split(",")
                            # 判断用户是否在所选择的1000个用户中
                            if userID in self.users_1000:
                                if random.randint(1,50) == 1:
                                    test.setdefault(userID, {})[movieID] = int(rate)
                                else:
                                    train.setdefault(userID, {})[movieID] = int(rate)
                print("加载数据到 data/train.json 和 data/test.json")
                json.dump(train,open("data/train.json","w"))
                json.dump(test,open("data/test.json","w"))
                print("加载数据完成")
            return train,test
    
        """
            计算皮尔逊相关系数
                rating1:用户1的评分记录,形式如{"movieid1":rate1,"movieid2":rate2,...}
                rating2:用户1的评分记录,形式如{"movieid1":rate1,"movieid2":rate2,...}
        """
        def pearson(self,rating1,rating2):
            sum_xy = 0
            sum_x = 0
            sum_y = 0
            sum_x2 = 0
            sum_y2 = 0
            num = 0
            for key in rating1.keys():
                if key in rating2.keys():
                    num += 1
                    x = rating1[key]
                    y = rating2[key]
                    sum_xy += x * y
                    sum_x += x
                    sum_y += y
                    sum_x2 += math.pow(x,2)
                    sum_y2 += math.pow(y,2)
            if num == 0:
                return  0
            # 皮尔逊相关系数分母
            denominator = math.sqrt( sum_x2 - math.pow(sum_x,2) / num) * math.sqrt( sum_y2 - math.pow(sum_y,2) / num )
            if denominator == 0:
                return  0
            else:
                return ( sum_xy - ( sum_x * sum_y ) / num ) / denominator
    
        """
            用户userID进行电影推荐
                userID:用户ID
        """
        def recommend(self,userID):
            neighborUser = dict()
            for user in self.train.keys():
                if userID != user:
                    distance = self.pearson(self.train[userID],self.train[user])
                    neighborUser[user]=distance
            # 字典排序
            newNU = sorted(neighborUser.items(),key = lambda k:k[1] ,reverse=True)
    
            movies = dict()
            for (sim_user,sim) in newNU[:self.k]:
                for movieID in self.train[sim_user].keys():
                    movies.setdefault(movieID,0)
                    movies[movieID] += sim * self.train[sim_user][movieID]
            newMovies = sorted(movies.items(), key = lambda  k:k[1], reverse=True)
            return newMovies
    
        """
            推荐系统效果评估函数
                num: 随机抽取 num 个用户计算准确率
        """
        def evaluate(self,num=30):
            print("开始计算准确率")
            precisions = list()
            random.seed(10)
            for userID in random.sample(self.test.keys(),num):
                hit = 0
                result = self.recommend(userID)[:self.n_items]
                for (item,rate) in result:
                    if item in self.test[userID]:
                        hit += 1
                precisions.append(hit/self.n_items)
            return  sum(precisions) / precisions.__len__()
    
    # main函数,程序的入口
    if __name__ == "__main__":
        file_path = "data/netflix/training_set"
        seed = 30
        k = 15
        n_items =20
        f_rec = FirstRec(file_path,seed,k,n_items)
        # 计算用户 195100 和 1547579的皮尔逊相关系数
        r = f_rec.pearson(f_rec.train["195100"],f_rec.train["1547579"])
        print("195100 和 1547579的皮尔逊相关系数为:{}".format(r))
        # 为用户195100进行电影推荐
        result = f_rec.recommend("195100")
        print("为用户ID为:195100的用户推荐的电影为:{}".format(result))
        print("算法的推荐准确率为: {}".format(f_rec.evaluate()))
    
    1. 结果
    随机选取1000个用户!
    从文件中加载训练集和测试集
    从文件中加载数据完成
    1951001547579的皮尔逊相关系数为:0.1194695382178992
    为用户ID为:195100的用户推荐的电影为:[('3938', 22.0), ('14538', 19.000000000000004), ('14103', 19.0), ('15205', 18.000000000000004), ('17355', 18.0), ('1905', 18.0), ('12317', 16.000000000000004), ('13255', 16.000000000000004), ('5317', 14.000000000000004), ('11283', 14.0), ('14240', 14.0), ('6974', 14.0), ('16265', 14.0), ('6206', 14.0), ('11521', 14.0), ('1145', 13.000000000000005), ('17169', 13.000000000000005), ('9340', 13.000000000000004), ('4306', 13.0), ('11132', 13.0), ('17324', 13.0), ('14313', 12.000000000000002), ('16879', 12.0), ('3917', 12.0), ('7624', 12.0), ('8644', 12.0), ('13593', 12.0), ('6844', 11.000000000000002), ('758', 11.0), ('313', 11.0), ('8393', 11.0), ('11089', 11.0), ('13050', 11.0), ('14454', 11.0), ('16882', 11.0), ('12911', 10.000000000000005), ('15582', 10.000000000000005), ('30', 10.0), ('14621', 10.0), ('16377', 10.0), ('5582', 10.0), ('9628', 10.0), ('3274', 10.0), ('5496', 10.0), ('16082', 10.0), ('10550', 9.999999999999998), ('1220', 9.999999999999998), ('1804', 9.999999999999998), ('12721', 9.999999999999998), ('12672', 9.000000000000005), ('6386', 9.0), ('12918', 9.0), ('13052', 9.0), ('5085', 9.0), ('6030', 9.0), ('7928', 9.0), ('9189', 9.0), ('12293', 9.0), ('14410', 9.0), ('14550', 9.0), ('14574', 9.0), ('223', 9.0), ('12161', 9.0), ('197', 9.0), ('1191', 9.0), ('3427', 9.0), ('13087', 9.0), ('17303', 9.0), ('1110', 9.0), ('15646', 9.0), ('17330', 9.0), ('2452', 9.0), ('3624', 9.0), ('13673', 9.0), ('996', 8.999999999999998), ('5577', 8.999999999999998), ('11022', 8.999999999999998), ('13258', 8.999999999999998), ('2152', 8.000000000000004), ('4972', 8.000000000000004), ('12470', 8.000000000000004), ('6972', 8.0), ('16668', 8.0), ('3756', 8.0), ('4123', 8.0), ('5087', 8.0), ('7406', 8.0), ('10583', 8.0), ('11607', 8.0), ('16452', 8.0), ('3894', 8.0), ('16242', 8.0), ('1406', 7.999999999999999), ('1962', 7.999999999999999), ('2342', 7.999999999999999), ('2862', 7.999999999999999), ('6134', 7.999999999999999), ('6615', 7.999999999999999), ('15563', 7.999999999999999), ('3638', 7.999999999999999), ('4384', 7.999999999999999), ('9818', 7.999999999999999), ('5320', 7.999999999999999), ('6475', 7.999999999999999), ('6859', 7.999999999999999), ('15063', 7.999999999999999), ('15099', 7.999999999999999), ('15409', 7.999999999999999), ('10729', 7.999999999999998), ('13380', 7.999999999999998), ('11149', 7.000000000000005), ('6287', 7.0000000000000036), ('14712', 7.000000000000001), ('3282', 7.0), ('11677', 7.0), ('15107', 7.0), ('15788', 7.0), ('4262', 7.0), ('12056', 7.0), ('14187', 7.0), ('10421', 7.0), ('13728', 6.999999999999999), ('17149', 6.999999999999999), ('9054', 6.999999999999999), ('11314', 6.999999999999999), ('11182', 6.999999999999998), ('5814', 6.999999999999998), ('2112', 6.999999999999998), ('4996', 6.0), ('7987', 6.0), ('12155', 6.0), ('6037', 6.0), ('3860', 5.999999999999999), ('10429', 5.999999999999999), ('571', 5.999999999999998), ('6648', 5.999999999999998), ('7060', 5.0), ('14533', 5.0), ('1102', 5.0), ('3962', 5.0), ('4356', 5.0), ('5531', 5.0), ('11040', 5.0), ('12870', 5.0), ('15101', 5.0), ('15296', 5.0), ('15844', 5.0), ('17157', 5.0), ('166', 5.0), ('199', 5.0), ('788', 5.0), ('1661', 5.0), ('17014', 5.0), ('17479', 5.0), ('762', 5.0), ('2989', 5.0), ('5285', 5.0), ('7429', 5.0), ('11370', 5.0), ('12433', 5.0), ('14302', 5.0), ('15124', 5.0), ('16147', 5.0), ('819', 5.0), ('937', 5.0), ('1364', 5.0), ('1542', 5.0), ('1590', 5.0), ('1914', 5.0), ('2023', 5.0), ('2140', 5.0), ('2162', 5.0), ('2254', 5.0), ('2326', 5.0), ('2594', 5.0), ('2612', 5.0), ('2953', 5.0), ('3807', 5.0), ('3825', 5.0), ('4829', 5.0), ('5875', 5.0), ('6119', 5.0), ('6194', 5.0), ('6448', 5.0), ('6482', 5.0), ('7186', 5.0), ('7617', 5.0), ('8192', 5.0), ('8339', 5.0), ('8595', 5.0), ('9036', 5.0), ('9188', 5.0), ('9326', 5.0), ('9471', 5.0), ('9756', 5.0), ('10123', 5.0), ('10359', 5.0), ('11433', 5.0), ('11805', 5.0), ('12766', 5.0), ('13090', 5.0), ('13217', 5.0), ('13462', 5.0), ('13810', 5.0), ('13851', 5.0), ('14167', 5.0), ('14755', 5.0), ('14963', 5.0), ('15170', 5.0), ('15755', 5.0), ('15798', 5.0), ('16139', 5.0), ('17053', 5.0), ('17250', 5.0), ('17441', 5.0), ('17707', 5.0), ('16128', 5.0), ('14376', 5.0), ('457', 5.0), ('1803', 5.0), ('3612', 5.0), ('4008', 5.0), ('4432', 5.0), ('6027', 5.0), ('6042', 5.0), ('8118', 5.0), ('8160', 5.0), ('11337', 5.0), ('12338', 5.0), ('12785', 5.0), ('13359', 5.0), ('17004', 5.0), ('17293', 5.0), ('17405', 5.0), ('17627', 5.0), ('290', 4.999999999999999), ('2913', 4.999999999999999), ('3138', 4.999999999999999), ('5695', 4.999999999999999), ('5947', 4.999999999999999), ('6366', 4.999999999999999), ('6450', 4.999999999999999), ('7193', 4.999999999999999), ('7713', 4.999999999999999), ('7786', 4.999999999999999), ('8966', 4.999999999999999), ('8993', 4.999999999999999), ('10189', 4.999999999999999), ('10986', 4.999999999999999), ('12367', 4.999999999999999), ('14264', 4.999999999999999), ('15209', 4.999999999999999), ('17339', 4.999999999999999), ('17449', 4.999999999999999), ('8954', 4.999999999999999), ('175', 4.999999999999999), ('210', 4.999999999999999), ('473', 4.999999999999999), ('561', 4.999999999999999), ('872', 4.999999999999999), ('1741', 4.999999999999999), ('1848', 4.999999999999999), ('2348', 4.999999999999999), ('2480', 4.999999999999999), ('3139', 4.999999999999999), ('3374', 4.999999999999999), ('4477', 4.999999999999999), ('5283', 4.999999999999999), ('5561', 4.999999999999999), ('5653', 4.999999999999999), ('5862', 4.999999999999999), ('6117', 4.999999999999999), ('6221', 4.999999999999999), ('6445', 4.999999999999999), ('6545', 4.999999999999999), ('6807', 4.999999999999999), ('6808', 4.999999999999999), ('7170', 4.999999999999999), ('7433', 4.999999999999999), ('7516', 4.999999999999999), ('7523', 4.999999999999999), ('7586', 4.999999999999999), ('7735', 4.999999999999999), ('8806', 4.999999999999999), ('8829', 4.999999999999999), ('8832', 4.999999999999999), ('8893', 4.999999999999999), ('8951', 4.999999999999999), ('9076', 4.999999999999999), ('9330', 4.999999999999999), ('9426', 4.999999999999999), ('10276', 4.999999999999999), ('10661', 4.999999999999999), ('11573', 4.999999999999999), ('11899', 4.999999999999999), ('12417', 4.999999999999999), ('12942', 4.999999999999999), ('14061', 4.999999999999999), ('14210', 4.999999999999999), ('14525', 4.999999999999999), ('15333', 4.999999999999999), ('15657', 4.999999999999999), ('16175', 4.999999999999999), ('16306', 4.999999999999999), ('16431', 4.999999999999999), ('16482', 4.999999999999999), ('16721', 4.999999999999999), ('17412', 4.999999999999999), ('17472', 4.999999999999999), ('270', 4.999999999999999), ('798', 4.999999999999999), ('985', 4.999999999999999), ('1256', 4.999999999999999), ('2938', 4.999999999999999), ('3078', 4.999999999999999), ('4345', 4.999999999999999), ('4577', 4.999999999999999), ('4951', 4.999999999999999), ('5309', 4.999999999999999), ('5414', 4.999999999999999), ('6034', 4.999999999999999), ('7057', 4.999999999999999), ('7155', 4.999999999999999), ('7158', 4.999999999999999), ('7230', 4.999999999999999), ('8438', 4.999999999999999), ('8840', 4.999999999999999), ('10988', 4.999999999999999), ('11271', 4.999999999999999), ('12184', 4.999999999999999), ('12453', 4.999999999999999), ('12530', 4.999999999999999), ('13663', 4.999999999999999), ('14961', 4.999999999999999), ('15070', 4.999999999999999), ('15307', 4.999999999999999), ('15609', 4.999999999999999), ('15689', 4.999999999999999), ('16083', 4.999999999999999), ('17023', 4.999999999999999), ('17328', 4.999999999999999), ('15151', 4.999999999999999), ('9939', 4.000000000000004), ('3610', 4.0), ('7635', 4.0), ('17431', 4.0), ('708', 4.0), ('759', 4.0), ('886', 4.0), ('1073', 4.0), ('1174', 4.0), ('1931', 4.0), ('2743', 4.0), ('3079', 4.0), ('3605', 4.0), ('4330', 4.0), ('4640', 4.0), ('5056', 4.0), ('6274', 4.0), ('6408', 4.0), ('6630', 4.0), ('6833', 4.0), ('7364', 4.0), ('9728', 4.0), ('10808', 4.0), ('12471', 4.0), ('13622', 4.0), ('13763', 4.0), ('13883', 4.0), ('14507', 4.0), ('14827', 4.0), ('15968', 4.0), ('16286', 4.0), ('17088', 4.0), ('660', 4.0), ('1646', 4.0), ('5084', 4.0), ('6362', 4.0), ('10982', 4.0), ('13923', 4.0), ('17426', 4.0), ('642', 4.0), ('8561', 4.0), ('283', 4.0), ('607', 4.0), ('896', 4.0), ('1045', 4.0), ('1610', 4.0), ('1625', 4.0), ('1645', 4.0), ('2430', 4.0), ('2541', 4.0), ('3021', 4.0), ('3127', 4.0), ('3242', 4.0), ('3542', 4.0), ('3737', 4.0), ('3905', 4.0), ('3999', 4.0), ('4263', 4.0), ('4533', 4.0), ('5421', 4.0), ('5503', 4.0), ('5897', 4.0), ('6281', 4.0), ('6555', 4.0), ('6692', 4.0), ('7019', 4.0), ('7076', 4.0), ('7077', 4.0), ('7633', 4.0), ('8253', 4.0), ('8278', 4.0), ('9205', 4.0), ('9617', 4.0), ('10809', 4.0), ('10921', 4.0), ('11103', 4.0), ('11669', 4.0), ('12101', 4.0), ('12102', 4.0), ('12273', 4.0), ('12299', 4.0), ('13523', 4.0), ('13656', 4.0), ('13805', 4.0), ('14144', 4.0), ('14149', 4.0), ('14593', 4.0), ('14856', 4.0), ('15048', 4.0), ('15247', 4.0), ('15540', 4.0), ('16339', 4.0), ('16516', 4.0), ('16724', 4.0), ('17035', 4.0), ('17559', 4.0), ('17743', 4.0), ('257', 4.0), ('3907', 4.0), ('5293', 4.0), ('7745', 4.0), ('8764', 4.0), ('12508', 4.0), ('13651', 4.0), ('15500', 4.0), ('15700', 4.0), ('16384', 4.0), ('17321', 4.0), ('273', 4.0), ('7234', 4.0), ('8204', 4.0), ('10255', 4.0), ('12739', 4.0), ('3526', 4.0), ('4315', 4.0), ('4522', 4.0), ('5284', 4.0), ('5621', 4.0), ('6060', 4.0), ('6267', 4.0), ('6329', 4.0), ('6437', 4.0), ('6698', 4.0), ('6874', 4.0), ('6971', 4.0), ('7852', 4.0), ('9662', 4.0), ('10358', 4.0), ('10906', 4.0), ('11812', 4.0), ('11910', 4.0), ('12600', 4.0), ('12966', 4.0), ('13330', 4.0), ('14467', 4.0), ('14999', 4.0), ('16380', 4.0), ('16707', 4.0), ('16793', 4.0), ('17174', 4.0), ('564', 4.0), ('1324', 4.0), ('2649', 4.0), ('3864', 4.0), ('4109', 4.0), ('5926', 4.0), ('6552', 4.0), ('7067', 4.0), ('9458', 4.0), ('13081', 4.0), ('13582', 4.0), ('14531', 4.0), ('14571', 4.0), ('14691', 4.0), ('14897', 4.0), ('16438', 4.0), ('16469', 4.0), ('16872', 4.0), ('14644', 3.9999999999999996), ('4914', 3.9999999999999996), ('8', 3.999999999999999), ('443', 3.999999999999999), ('2580', 3.999999999999999), ('3125', 3.999999999999999), ('5345', 3.999999999999999), ('5762', 3.999999999999999), ('6131', 3.999999999999999), ('6454', 3.999999999999999), ('6518', 3.999999999999999), ('6917', 3.999999999999999), ('7517', 3.999999999999999), ('8801', 3.999999999999999), ('8976', 3.999999999999999), ('9778', 3.999999999999999), ('10433', 3.999999999999999), ('10582', 3.999999999999999), ('11227', 3.999999999999999), ('12534', 3.999999999999999), ('12838', 3.999999999999999), ('13015', 3.999999999999999), ('14233', 3.999999999999999), ('14274', 3.999999999999999), ('14549', 3.999999999999999), ('16240', 3.999999999999999), ('16495', 3.999999999999999), ('17033', 3.999999999999999), ('17184', 3.999999999999999), ('17312', 3.999999999999999), ('6829', 3.999999999999999), ('14527', 3.999999999999999), ('15483', 3.999999999999999), ('599', 3.999999999999999), ('1466', 3.999999999999999), ('2175', 3.999999999999999), ('2965', 3.999999999999999), ('3106', 3.999999999999999), ('3879', 3.999999999999999), ('4139', 3.999999999999999), ('7384', 3.999999999999999), ('7419', 3.999999999999999), ('8526', 3.999999999999999), ('10004', 3.999999999999999), ('10162', 3.999999999999999), ('10662', 3.999999999999999), ('10832', 3.999999999999999), ('10920', 3.999999999999999), ('11295', 3.999999999999999), ('11575', 3.999999999999999), ('11904', 3.999999999999999), ('12360', 3.999999999999999), ('13082', 3.999999999999999), ('13186', 3.999999999999999), ('13317', 3.999999999999999), ('13909', 3.999999999999999), ('16810', 3.999999999999999), ('1144', 3.999999999999999), ('3538', 3.999999999999999), ('4570', 3.999999999999999), ('5939', 3.999999999999999), ('7233', 3.999999999999999), ('7331', 3.999999999999999), ('14215', 3.999999999999999), ('17215', 3.999999999999999), ('17762', 3.999999999999999), ('2192', 3.999999999999999), ('3347', 3.999999999999999), ('13342', 3.999999999999999), ('5071', 3.0000000000000036), ('12694', 3.0000000000000036), ('3197', 3.0), ('4745', 3.0), ('7446', 3.0), ('8782', 3.0), ('11064', 3.0), ('11837', 3.0), ('12343', 3.0), ('15339', 3.0), ('16765', 3.0), ('720', 3.0), ('1180', 3.0), ('1673', 3.0), ('2874', 3.0), ('3730', 3.0), ('4043', 3.0), ('4488', 3.0), ('5952', 3.0), ('6347', 3.0), ('7649', 3.0), ('8784', 3.0), ('9381', 3.0), ('10042', 3.0), ('10423', 3.0), ('10818', 3.0), ('13384', 3.0), ('13413', 3.0), ('13636', 3.0), ('13827', 3.0), ('13845', 3.0), ('14367', 3.0), ('14653', 3.0), ('15902', 3.0), ('16792', 3.0), ('16891', 3.0), ('2678', 3.0), ('3434', 3.0), ('3772', 3.0), ('5819', 3.0), ('7032', 3.0), ('14977', 3.0), ('5528', 3.0), ('5760', 3.0), ('8799', 3.0), ('14278', 3.0), ('2518', 3.0), ('4092', 3.0), ('5604', 3.0), ('6311', 3.0), ('7322', 3.0), ('10789', 3.0), ('15529', 3.0), ('17129', 3.0), ('17175', 3.0), ('17381', 3.0), ('16113', 3.0), ('11681', 3.0), ('15641', 3.0), ('1138', 3.0), ('5793', 3.0), ('5828', 3.0), ('5836', 3.0), ('6860', 3.0), ('7184', 3.0), ('7281', 3.0), ('8295', 3.0), ('10860', 3.0), ('11931', 3.0), ('12322', 3.0), ('14113', 3.0), ('15764', 3.0), ('312', 2.999999999999999), ('1283', 2.999999999999999), ('2779', 2.999999999999999), ('2958', 2.999999999999999), ('3151', 2.999999999999999), ('4493', 2.999999999999999), ('4695', 2.999999999999999), ('6497', 2.999999999999999), ('7238', 2.999999999999999), ('7971', 2.999999999999999), ('9415', 2.999999999999999), ('9442', 2.999999999999999), ('10773', 2.999999999999999), ('13061', 2.999999999999999), ('13214', 2.999999999999999), ('14890', 2.999999999999999), ('14940', 2.999999999999999), ('15343', 2.999999999999999), ('17062', 2.999999999999999), ('17111', 2.999999999999999), ('9645', 2.999999999999999), ('15034', 2.999999999999999), ('963', 2.999999999999999), ('1464', 2.999999999999999), ('406', 2.999999999999999), ('442', 2.999999999999999), ('2172', 2.999999999999999), ('2942', 2.999999999999999), ('4877', 2.999999999999999), ('5154', 2.999999999999999), ('7739', 2.999999999999999), ('8535', 2.999999999999999), ('10375', 2.999999999999999), ('11047', 2.999999999999999), ('11090', 2.999999999999999), ('11696', 2.999999999999999), ('13736', 2.999999999999999), ('15471', 2.999999999999999), ('305', 2.999999999999999), ('1307', 2.999999999999999), ('10101', 2.999999999999999), ('12303', 2.999999999999999), ('28', 2.0), ('6720', 2.0), ('12774', 2.0), ('15474', 2.0), ('1700', 2.0), ('2226', 2.0), ('16095', 2.0), ('17345', 2.0), ('1068', 2.0), ('11170', 2.0), ('6255', 2.0), ('8418', 2.0), ('17031', 2.0), ('17251', 2.0), ('331', 2.0), ('2477', 2.0), ('7249', 2.0), ('10947', 2.0), ('13519', 2.0), ('16640', 2.0), ('16859', 2.0), ('468', 1.9999999999999996), ('2856', 1.9999999999999996), ('4733', 1.9999999999999996), ('6084', 1.9999999999999996), ('8824', 1.9999999999999996), ('10078', 1.9999999999999996), ('13565', 1.9999999999999996), ('13855', 1.9999999999999996), ('14440', 1.9999999999999996), ('14898', 1.9999999999999996), ('15608', 1.9999999999999996), ('16603', 1.9999999999999996), ('16730', 1.9999999999999996), ('17704', 1.9999999999999996), ('9800', 1.9999999999999996), ('658', 1.9999999999999996), ('2391', 1.9999999999999996), ('2486', 1.9999999999999996), ('5837', 1.9999999999999996), ('10775', 1.9999999999999996), ('15777', 1.9999999999999996), ('3314', 1.9999999999999996), ('4590', 1.9999999999999996), ('7521', 1.9999999999999996), ('11065', 1.9999999999999996), ('13043', 1.9999999999999996), ('14389', 1.9999999999999996), ('17387', 1.000000000000001), ('1975', 1.0), ('2361', 1.0), ('4103', 1.0), ('5725', 1.0), ('16145', 1.0), ('191', 1.0), ('6975', 1.0), ('14332', 1.0), ('3713', 1.0), ('7904', 1.0), ('5991', 1.0), ('6596', 1.0), ('1012', 0.9999999999999998), ('2939', 0.9999999999999998), ('7780', 0.9999999999999998), ('3161', 0.9999999999999998), ('13471', 0.9999999999999998), ('14154', 0.9999999999999998)]
    开始计算准确率
    算法的推荐准确率为: 0.005000000000000001
    
    1. 总结
      只是抽取的1000个训练,结果并不是很理想,全部训练集基数大,估计可行
      后期有时间放上GPU结果
    展开全文
  • 推荐系统项目基础(四)推荐系统的冷启动推荐系统的冷启动概念用户的冷启动物品的冷启动系统的冷启动 推荐系统的冷启动概念 本质是推荐系统依赖历史数据,没有历史数据没有办法预测用户偏好。 用户的冷启动 1、尽...

    推荐系统项目基础(四)推荐系统的冷启动

    推荐系统的冷启动概念

    本质是推荐系统依赖历史数据,没有历史数据没有办法预测用户偏好。

    用户的冷启动

    1、尽可能的收集用户特征,构建用户画像。
    例如注册信息,年龄,地域,性别等
    2、引导用户填写兴趣
    3、使用其他站点的行为数据
    4、新老用户的推荐策略的差异

    • 新用户在冷启动阶段更倾向于热门排行榜
    • ee力度
    • 使用单独的特征和模型预估

    物品的冷启动

    1、给物品打标签
    2、利用物品的内容信息,投放给曾经喜欢过和它内容相似的其他物品的用户。

    系统的冷启动

    1、系统早期,基于内容的推荐
    2、逐渐由内容的推荐转向标签的推荐
    3、基于内容的推荐和协同过滤的结果都计算出来进行加权。

    展开全文
  • 基于Flink商品实时推荐系统项目
    展开全文
  • RecommenderSystem 推荐系统项目模板 bridge--MQ cfgMgr--推荐 common--公用jar包 mover--redis sdk server--restAPI
  • 电影推荐系统 这是基于协作过滤方法的电影推荐系统项目
  • 推荐系统 此回购协议是为推荐系统项目Summer'18创建的 资源 我是Shantanu Bhardwaj,CSE,'20 Ayush Mittal,IT,2016-2020年。
  • 推荐系统项目基础(五)基于内容的推荐基于内容的推荐算法基于内容的推荐与基于物品协同过滤 基于内容的推荐算法 所谓基于内容的推荐算法(Content-Based Recommendations)是基于标的物相关信息、用户相关信息及用户...

    推荐系统项目基础(五)基于内容的推荐

    基于内容的推荐算法

    所谓基于内容的推荐算法(Content-Based Recommendations)是基于标的物相关信息、用户相关信息及用户对标的物的操作行为来构建推荐算法模型,为用户提供推荐服务。这里的标的物相关信息可以是对标的物文字描述的metadata信息、标签、用户评论、人工标注的信息等。或者是本身内容的相关标签(例如通过tfidf,Word2vec的方式进行向量计算)。

    其核心是基于画像(特征)进行推送。

    实施步骤:

    • 构造物品的特征是属性
    • 计算物品之间的相识度,相识度的计算依赖于属性值,相识度的算法可以是pearson系数,consin相识度,欧式距离等
    • 计算用户对相似物品的喜好程度
    • 推送评分高的物品给用户

    基于内容与基于物品推荐的区别

    基于内容与基于物品协同过滤推荐的相同点

    • 都是基于物品的相似度计算得到的

    基于内容与基于物品协同过滤推荐的区别

    • 基于物品协同过滤中需要从实际生产数据中获取信息,通过用户与物品的矩阵获取物品的相似度
    • 针对内容的获取,不需要线上的数据,只需要内容中进行提取向量即可
    展开全文
  • 基于知识图谱的推荐系统项目完整代码 数据集在data文件夹下 数据集为txt模式,分为训练集、验证集以及测试集
  • 课程定位* 课程是机器学习(包含推荐算法)算法原理在推荐系统的实践* 深入推荐系统的业务流场景、工具使用* 作为人工智能的数据挖掘(推荐系统)方向应用项目## 课程目标* 熟练掌握推荐系统的实时推荐业务流* 熟练掌握...
  • 机器学习与推荐系统 机器学习算法源码与推荐系统项目实现
  • 推荐系统项目–菜谱推荐测试 本文主要介绍我厂菜谱推荐项目个人的测试思路。此项目不同于像淘宝,亚马逊,抖音这样的推荐,一没这么大的用户量,二也没那么多内容,所以有些测试方法会不适用些项目,测试方法也较大...
  • 1、点评搜索服务&推荐系统项目概述

    千次阅读 2020-05-05 03:44:03
    推荐系统项目概述项目设计业务需求技术分解&模块设计小结 整理总结一下 ElasticSearch7+Spark 构建高相关性搜索服务&千人千面推荐系统的笔记 完成一个点评搜索推荐项目 SpringBoot、ElasticSearch、Sp...
  • 基于Hadoop的好友推荐系统项目综述

    万次阅读 多人点赞 2017-07-15 14:06:30
    一、好友推荐系统项目概述1、项目介绍该系统利用基于密度的新型聚类算法,对给定用户基于好友推荐。本系统的开发IDE采用eclipse,使用maven构建项目,数据库选用Mysql,后台技术采用Struts2+Hibernate+Spring的架构...
  • 大数据推荐系统项目

    2019-09-20 16:42:39
    推荐系统的本思想 • 利用用户和物品的特征信息,给用户推荐那些具有用户喜欢的特征的物品。 • 利用用户喜欢过的物品,给用户推荐与他喜欢过的物品相似的物品。 • 利用和用户相似的其他用户,给用户推荐那些...
  • 推荐系统项目整理

    千次阅读 2019-08-11 22:35:58
    物品元数据:来源于内容管理系统,通过flume采集至HDFS 二. 推荐算法(粗排) 基于内容的推荐(简称CB): (1)将HDFS中的物品元数据写入Hbase倒排表 (2)读取Hbase倒排表中数据20w+索引数据,以token(关键词)为r....
  • awesome-project-ideas:机器学习,NLP,视觉,推荐系统项目创意的精选清单
  • 目录:/2019最新 Python黑马头条推荐系统项目 [5.9G] TouTiaoRecoSysCourseware每天代码资料.zip [91.6M] 黑马头条推荐第一天.rar [791.3M] 黑马头条推荐第七天.rar [878.9M] 黑马头条推荐第三天.rar [796.5M] ...
  • 项目架构 项目过程中的数据转换 注意:图中RDD后跟的不是元素类型,而是其中元素的含义,如:...商品推荐优先级计算(实时推荐阶段) def computeProductScores( simProducts:scala.collection.Map[Int,scala....
  • 推荐系统项目基础(二)协同过滤协同过滤算法用户协同过滤User-based CF商品协同过滤Item-based CF计算相似度余弦相似度皮尔逊相似度Jarccard相似度基于Jarccard相似度计算例子 协同过滤算法 用户协同过滤User-based...
  • 推荐系统项目基础(三)基于模型的协同过滤基于图的协同过滤算法基于矩阵分解的协同过滤算法Funk SVD计算funk SVD矩阵方式ALS交替最小二乘法梯度下降算法 基于图的协同过滤算法 基于相邻域的模型可以看做基于图的...
  • 推荐系统项目实战篇

    2020-03-14 20:44:56
  • 电影推荐系统项目 介绍(一)

    千次阅读 2020-03-19 18:04:24
    1.、推荐系统是什么? 信息过载时代所采用的措施。面对海量的数据信息,从中快速推荐出符合用户特点的物品。 受众:没有明确需求的人;"选择困难症"。 没有推荐系统: 分类目录,搜索引擎 有弊端:信息量小,...
  • 电影推荐系统项目 实时推荐(十)

    千次阅读 2020-04-29 23:32:10
    实时推荐一.新鲜一感二.实时推荐代码 一.新鲜一感 愿世界上所有的爱和美好都被辜负 二.实时推荐代码 回顾: 上一篇已经做好了, 电影相似度矩阵计算. 任务: 做实时推荐代码 代码实现: 1.StreamingRecommender...
  • Nginx负载均衡分配到很多Tomcat上 右侧是大数据工程师做的
  • 电影推荐系统项目的数据处理部分

    千次阅读 2018-11-08 17:27:00
    项目架构 前期工作:数据加载 离线推荐 统计推荐 ALS离线推荐 实时推荐 这个项目的整体业务逻辑是通过Spring进行搭建,并部署在Tomcat上的。业务产生的数据一部分被存储到mongoDB并用于spark ...
  • 电商推荐系统项目工作总结

    千次阅读 2018-11-17 17:58:23
    电商推荐系统总结: 一. 数据清洗 < 1 >. 数据集中是否存在缺失值,处理缺失值。 处理数据集中缺失值的策略大概分为删除,补齐和忽略三类。组删除:将含有缺失值的属性特征删除(电商推荐中一般不采取此方法,...
  • 架构与业务流 基础数据层: 包括业务数据和用户... 召回 排序 点击率预估模型 特征处理、模型评价 推荐业务层:通过对外提供rpc接口来实现推荐业务的接入 Feed流推荐:今日推荐场景,用户可以在这些页面中不断下拉刷新
  • 这是我开发的一个游戏推荐系统项目,目的是将一些机器学习技术付诸实践,因此目标是使用户添加他已经玩过的游戏并将其添加到他的个人资料中,并在以后收到推荐。新游戏。 项目结构 . └── Game-Recommendation-...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 11,197
精华内容 4,478
关键字:

推荐系统项目