转载请注明出处:http://blog.csdn.net/chen19920219/article/details/76905381
最近在GitHub上发现了一个很好的开源推荐系统,Star700多,包含了常用的矩阵分解算法,包括SVD,SVD++,NMF等等,GitHub地址:https://github.com/NicolasHug/Surprise,由于安装和使用过程中有许多坑,特此记录下来:
Surprise安装
官方文档中显示安装环境为Python2.7或者3.5,我的环境为3.5,其他没试过。
首先,文档显示有两种安装方法,这里使用第一种安装方法
$ pip install numpy
$ pip install scikit-surprise
在安装之前首先确认安装了numpy模块,然后在安装surprise时,老是报错,错误为unable to findvcvarsall.bat,网上搜了下解决办法链接为:
http://jingyan.baidu.com/article/adc815138162e8f723bf7387.html
然后重新pipinstall scikit-surprise就好了。
Surprise 使用
Surprise里有自带的数据集,自带的数据集加载方法和加载自己数据集的方法不同。加载项目提供的数据集就不多说了,这里重点说下Surprise怎么加载自己本地的数据集以及经常使用的方法。
官方API提供了加载本地数据集的方法:
Load a custom dataset
You can of course use a custom dataset. Surprise offerstwo ways of loading a custom dataset:
· you can either specify a single file with all the ratingsand use the split () method to performcross-validation ;
· or if your dataset is already split into predefinedfolds, you can specify a list of files for training and testing.
Either way, you will need to define a