零基础入门推荐系统 - 新闻推荐 (1)

本文介绍了天池零基础推荐系统比赛,赛题要求预测用户未来点击的新闻文章。通过理解赛题,建立了基于ItemCF的协同过滤baseline模型,包括数据处理、相似度计算和推荐文章生成,最终生成提交文件。
摘要由CSDN通过智能技术生成

零基础入门推荐系统 - 新闻推荐 (1)

本文是跟随Datawhale组队学习推荐系统笔记。以天池零基础入门推荐系统 - 新闻推荐比赛为例,学习推荐系统相关内容。
原文地址:https://tianchi.aliyun.com/notebook-ai/detail?spm=5176.12586969.1002.15.4105d75fc3WKWF&postId=144449

赛题理解

赛题以预测用户未来点击新闻文章为任务,该数据来自某新闻APP平台的用户交互数据,包括30万用户,近300万次点击,共36万多篇不同的新闻文章,同时每篇新闻文章有对应的embedding向量表示。为了保证比赛的公平性,将会从中抽取20万用户的点击日志数据作为训练集,5万用户的点击日志数据作为测试集A,5万用户的点击日志数据作为测试集B。

此次比赛目标:根据用户历史浏览点击新闻的数据信息预测用户最后一次点击的新闻文章。可以预测用户最后一次点击某文章的概率,概率最大的就是最可能点击的新闻文章。

这样就把问题转变为点击率预测的问题(用户,文章)–>点击的概率。

Baseline

导包

import time, math, os
from tqdm import tqdm
import gc
import pickle
import random
from datetime import datetime
from operator import itemgetter
import numpy as np
import pandas as pd
import warnings
from collections import defaultdict
import collections
warnings.filterwarnings('ignore')
data_path='d:/data/'
save_path='d:/data/temp_results/'

df节省内存函数

# 节约内存的一个标配函数
def reduce_mem(df):
    starttime = time.time()
    numeric = ['int16','int32','int64','float16','float32','float64']
    start_mem = df.memory_usage().sum()/1024**2
    for col in df.columns:
        col_type = df[col].dtypes
        if col_type in numerics:
            c_min = df[col].min()
            c_max = df[col].max()
            if pd.isnull(c_min) or pd.isnull(c_max):
                continue
            if str(col_type)[:3] == 'int':
                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:
                    df[col] = df[col].astype(np.int8)
                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:
                    df[col] = df[col].astype(np.int16)
                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:
                    df[col] = df[col].astype(np.int32)
                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:
                    df[col] = df[col].astype(np
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值