使用Matlab或Python将用户项目评分转换为矩阵市场输入格式 [英] Converting User Item Rating Into Matrix Market Input format using Matlab or Python

查看:315
本文介绍了使用Matlab或Python将用户项目评分转换为矩阵市场输入格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我有一个数据集,其中的条目均为

Sir, I have a dataset in which entries are in the form

userid | itemid | rating

userid|itemid|rating

我想使用Matlab或python将此评级更改为矩阵市场输入格式

I want to change this rating into matrix market input format using matlab or python

请帮帮我.

推荐答案

在matlab中是这样的(尚未检查代码,您可能还需要进行一些转换):

It is something like this in matlab (not checked yet the code, you might need a couple transposing too):

fid = fopen('exp.txt');
A = fscanf(fid, '%d|%d|%g', [3 inf]);
S = sparse(A(1,:), A(2,:), A(3,:))

读取文件的参考.
关于稀疏矩阵的参考.

这篇关于使用Matlab或Python将用户项目评分转换为矩阵市场输入格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆