资源简介

java实现的几个推荐算法:slopeone SVD,RSVD,ItemNeighborSVD 内有readme,相关内容在blog.csdn.net/lgnlgn

资源截图

代码片段和文件信息

import sys
import random
def regeneration(filein percent = 0.14):
    f = open(filein)
    ftrain = open(filein + “.train“ ‘w‘)
    ftest = open( filein + “.test“ ‘w‘)
    fw = ftrain
    items = {}
    users = {}
    flag = True
    maxuid = 0
    for line in f.xreadlines():
        uid mid rating timestamp = line.split(“::“)
        newmid = items.get(mid)
        newuid = users.get(uid)
        if newmid == None:
            newmid = len(items) + 1
            items[mid] =  newmid
        if newuid == None:
            newuid = len(users) + 1
            users[uid] = newuid
        if newuid < maxuid:
            flag = False
        if random.random() <= percent:
            fw = ftest
        else:
            fw = ftrain
        fw.write(“%d%d%s%s“ %(newuid newmid rating timestamp)) ## timestamp has a ‘\n‘
    print “USERID ORDER BY ASC : “ flag
    fw.close()
    f.close()

if __name__ == ‘__main__‘:
##    regeneration(sys.argv[1] float(sys.argv[2]))
    regeneration(r“E:\data\ml-10m\ml-10M100K\ratings.dat“)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-12-26 16:53  dami\
     文件         393  2011-12-26 16:53  dami\.classpath
     文件         556  2011-12-23 12:28  dami\.project
     目录           0  2011-12-23 12:28  dami\.settings\
     文件          88  2011-12-22 16:18  dami\.settings\org.eclipse.core.resources.prefs
     文件         695  2011-12-23 12:38  dami\.settings\org.eclipse.jdt.core.prefs
     文件         121  2011-12-23 12:28  dami\.settings\org.eclipse.m2e.core.prefs
     目录           0  2012-01-04 20:16  dami\bin\
     目录           0  2011-12-19 15:23  dami\bin\org\
     目录           0  2011-12-21 20:24  dami\bin\org\lgn\
     目录           0  2011-12-21 20:24  dami\bin\org\lgn\recommend\
     目录           0  2011-12-22 10:02  dami\bin\org\lgn\recommend\stars\
     目录           0  2011-12-23 10:10  dami\bin\org\lgn\recommend\stars\common\
     文件         665  2011-12-22 16:18  dami\bin\org\lgn\recommend\stars\common\Constants.class
     文件        2344  2011-12-23 10:10  dami\bin\org\lgn\recommend\stars\common\DataSet$FileDataSet.class
     文件        2591  2011-12-23 10:10  dami\bin\org\lgn\recommend\stars\common\DataSet$MemDataSet.class
     文件        1006  2011-12-23 10:10  dami\bin\org\lgn\recommend\stars\common\DataSet.class
     文件        1250  2011-12-22 16:18  dami\bin\org\lgn\recommend\stars\common\Evaluator.class
     文件         370  2011-12-22 16:18  dami\bin\org\lgn\recommend\stars\common\Model.class
     文件         844  2011-12-23 09:38  dami\bin\org\lgn\recommend\stars\common\RatingInfo.class
     文件        1871  2011-12-22 16:18  dami\bin\org\lgn\recommend\stars\common\Utilities.class
     目录           0  2011-12-22 15:49  dami\bin\org\lgn\recommend\stars\model\
     文件        4051  2011-12-22 19:22  dami\bin\org\lgn\recommend\stars\model\RSVDModel.class
     文件        5521  2011-12-22 19:29  dami\bin\org\lgn\recommend\stars\model\SimpleFactorizationModel.class
     文件        5380  2011-12-22 17:03  dami\bin\org\lgn\recommend\stars\model\SimpleFactorizationModel2.class
     目录           0  2011-12-22 16:36  dami\bin\org\lgn\recommend\stars\test\
     文件        1940  2011-12-22 16:41  dami\bin\org\lgn\recommend\stars\test\TestRSVDModel.class
     文件        1963  2011-12-22 19:26  dami\bin\org\lgn\recommend\stars\test\TestSimpleModel.class
     文件        2051  2011-12-23 11:05  dami\bin\org\lgn\recommend\stars\test\TestSimpleModel2.class
     目录           0  2011-12-23 12:30  dami\conf\
     文件         351  2011-12-23 12:28  dami\pom.xml
............此处省略76个文件信息

评论

共有 条评论