当前位置: 首页>>代码示例>>Python>>正文


Python SVD.load_data方法代码示例

本文整理汇总了Python中recsys.algorithm.factorize.SVD.load_data方法的典型用法代码示例。如果您正苦于以下问题:Python SVD.load_data方法的具体用法?Python SVD.load_data怎么用?Python SVD.load_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在recsys.algorithm.factorize.SVD的用法示例。


在下文中一共展示了SVD.load_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SVDloadData

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def SVDloadData():
    svd = SVD()
    recsys.algorithm.VERBOSE = True
    dat_file = '/home/commons/RecSys/MOVIEDATA/MOVIEDATA/ml-1m/ratings.dat'
    svd.load_data(filename=dat_file, sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
    print svd.get_matrix()
    return svd
开发者ID:craigsakuma,项目名称:Data_Science,代码行数:9,代码来源:RecommendationSystem_fxns.py

示例2: recommend

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def recommend(dimension=100): 
    svd = SVD()
    svd.load_data(filename='rating.dat',
                sep='\t',
                format={'col':2, 'row':1, 'value':0, 'ids': int})

    k = dimension
    svd.compute(k=k, min_values=1, pre_normalize=None, mean_center=True, post_normalize=True)
    
    game_recdict={}
    for item in svd.recommend(1, is_row=False):
        appid=item[0]
        game=Game(appid)
        if (game.success==1):
            game_recdict[game.rec]=[game.appid, game.genre, game.name, game.img]
        
    sorted_list=sorted(game_recdict.keys(), reverse=True)
    print ("Games Recommended:")
    for i in sorted_list:
        # image
        urllib.urlretrieve(game_recdict[i][3], "local-filename.jpg")
        image = plt.imread("local-filename.jpg")
        plt.imshow(image)
        plt.show()
    
        #name
        print game_recdict[i][2]
开发者ID:Sapphirine,项目名称:Game-recommendation-on-Steam,代码行数:29,代码来源:game.py

示例3: setup

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def setup():
    global users, items, svd

    print 'Reading items...'
    items = _read_items(os.path.join(MOVIELENS_DATA_PATH, 'movies.dat'))
    users = []

    svd = SVD()
    svd.load_data(filename=os.path.join(MOVIELENS_DATA_PATH, 'ratings.dat'), sep='::', format={'col':0, 'row':1, 'value':2, 'ids':int})
开发者ID:1060460048,项目名称:python-recsys,代码行数:11,代码来源:test_algorithm.py

示例4: getSVD

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def getSVD():
    filename = "/home/udaysagar/Documents/Classes/239/recsys/model/movielens.zip"
    if os.path.exists(filename):
        return SVD("./model/movielens")
    else:
        svd = SVD()
        svd.load_data(filename='./data/movielens/ratings.dat', sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
        k = 100
        svd.compute(k=k, min_values=10, pre_normalize=None, mean_center=True, post_normalize=True, savefile='./model/movielens')
        return svd
开发者ID:udaysagar2177,项目名称:predictMovieRatings,代码行数:12,代码来源:main.py

示例5: calculate_SVD_features

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def calculate_SVD_features():
    print "Thanks for input, calculating..."
    svd = SVD()
    recsys.algorithm.VERBOSE = True
    dat_file = 'feature_matrix.csv'
    svd.load_data(filename=dat_file, sep=',', 
                format = {'col':0, 'row':1, 'value': 2, 'ids': int})
    svd.compute(k=100, min_values=0, pre_normalize=None, 
                mean_center=False, post_normalize=True)
    return svd       
开发者ID:setman85,项目名称:Rest_Recs,代码行数:12,代码来源:rec2.py

示例6: calculate_SVD_users

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def calculate_SVD_users():
    print "Thanks for input, calculating..."
    svd = SVD()
    recsys.algorithm.VERBOSE = True
    dat_file = 'user_data_working.csv'
    svd.load_data(filename=dat_file, sep=',', 
                format = {'col':0, 'row':1, 'value': 2, 'ids': int})
    svd.compute(k=100, min_values=2, pre_normalize=None, 
                mean_center=True, post_normalize=True)
    shutil.copy('user_data_original.csv','user_data_working.csv')
    return svd
开发者ID:setman85,项目名称:Rest_Recs,代码行数:13,代码来源:rec2.py

示例7: get_model

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def get_model(model_name,datasource_name,start,end,model_params):
    if not model_name in model_data:
        model_data[model_name] = (datasource_name,start,end,model_params) 
    if not os.path.exists(model_dir+model_name):
        #initialize model with new data
        svd = SVD()
        svd.load_data(filename=data_dir+datasource_name+'.csv', sep=',', format={'col':0, 'row':1, 'value':2, 'ids': int})
        models[model_name] = svd
    else:
        if not model_name in models:
            models[model_name] = SVD(filename=model_dir+model_name)
开发者ID:delvv,项目名称:easyML-lib,代码行数:13,代码来源:itemRecommender.py

示例8: impute_to_file

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
 def impute_to_file(self, tastings, k=100, min_values=2, verbose=True):
     # create a data file in Movielens format with the tastings data
     self.save_tastings_to_movielens_format_file(tastings)
     # for logging/testing purposes we may like this verbose
     if verbose:
         recsys.algorithm.VERBOSE = True
     svd = SVD()
     # load source data, perform SVD, save to zip file
     source_file = self.file_location(self.tastings_movielens_format)
     svd.load_data(filename=source_file, sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
     outfile = self.file_location(self.tastings_recsys_svd)
     svd.compute(k=k, min_values=min_values, pre_normalize=None, mean_center=True, post_normalize=True, savefile=outfile)
     return svd
开发者ID:pgchamberlin,项目名称:sommelier,代码行数:15,代码来源:recommender.py

示例9: compute

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def compute(aws_region, s3_bucket, filename, sep, col_index, row_index, value_index, ids_type):
    download_from_s3(aws_region, s3_bucket, filename)
    svd = SVD()

    print 'Loading data to SVD module'
    svd.load_data(filename='./data/' + filename,
                  sep=sep,
                  format={'col':int(col_index), 'row':int(row_index), 'value':int(value_index), 'ids': ids_type})

    k = derive_latent_dimensions(svd, energy_level=0.6)

    print 'Stating to compute SVD at ', strftime("%Y-%m-%d %H:%M:%S", gmtime())
    svd.compute(k=k,
                min_values=10,
                pre_normalize=None,
                mean_center=True,
                post_normalize=True,
                savefile='./models/recommender')
    print "SVD model saved at ", strftime("%Y-%m-%d %H:%M:%S", gmtime())
    sys.exit() # to make sure that process finishes at the end
开发者ID:ayoo,项目名称:aws-recommender-system,代码行数:22,代码来源:computer.py

示例10: loadSVD

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def loadSVD():        
    
    filename = 'favRate.dat'
    svd = SVD()
    svd.load_data(filename=filename, sep='::', format={'col':0, 'row':1, 'value':2})
    
    svd.save_data("svd.dat", False)
    
    K=20
    svd.compute(k=K, min_values=1, pre_normalize="rows", mean_center=False, post_normalize=True, savefile='.')
    
    
    #svd.recommend(USERID, n=10, only_unknowns=True, is_row=False)
    
    sparse_matrix = svd.get_matrix()
    
    sim_matrix = svd.get_matrix_similarity()
    
    
    
    print sparse_matrix
    
    #print sim_matrix
    
    #1173893,1396943
    sim = svd.similar(897346, 10)
    
    filename = 'swoffering.yaml'
    titleStream = file(filename, 'r')
    titleList = yaml.load(titleStream)
    
    #print sim
    
    for row in sim:
        
        (offid, similar) = row
        
        print offid, titleList[str(offid)], similar        
开发者ID:riverhuang82,项目名称:recomov,代码行数:40,代码来源:recommendFav.py

示例11: quickstart

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def quickstart():
    svd = SVD()
    recsys.algorithm.VERBOSE = True

    # load movielens data
    dat_file = 'ml-1m/ratings.dat'
    svd.load_data(filename=dat_file, sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})

    # compute svd
    k = 100
    svd.compute(k=k, min_values=10, pre_normalize=None, mean_center=True,
        post_normalize=True)

    pdb.set_trace()

    # movie id's
    ITEMID1 = 1      # toy story
    ITEMID2 = 1221   # godfather II

    # get movies similar to toy story
    svd.similar(ITEMID1)

    # get predicted rating for given user & movie
    MIN_RATING = 0.0
    MAX_RATING = 5.0
    USERID = 1
    ITEMID = 1

    # get predicted rating
    pred = svd.predict(ITEMID, USERID, MIN_RATING, MAX_RATING)
    actual = svd.get_matrix().value(ITEMID, USERID)
    print 'predicted rating = {0}'.format(pred)
    print 'actual rating = {0}'.format(actual)

    # which users should see Toy Story?
    svd.recommend(ITEMID)
开发者ID:AkiraKane,项目名称:GA_Data_Science,代码行数:38,代码来源:recsys_ex.py

示例12: Compute

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def Compute():
	svd = SVD()
	svd.load_data(filename='./ml-1m/ratings.dat', sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
	svd.compute(k=100, min_values=10, pre_normalize=None, mean_center=True, post_normalize=True, savefile='./mvsvd')
开发者ID:satvikk,项目名称:Recommender,代码行数:6,代码来源:trout1.py

示例13: U

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
#This algorithm is called singular value decomposition and is used to compute the model from the ratings.csv file
#This needs to be run only once. The computed model is created as a zip folder. 
# U(Sigma)V^T is the mathematical formula used for computing SVD. using the pyrecsys library to implement the SVD algorithm
#Refer to docs for more details on SVD. 

import recsys.algorithm
from recsys.algorithm.factorize import SVD


#To obtain make the script verbose.
recsys.algorithm.VERBOSE = True

#computing the SVD model
svd = SVD()
#loading the ratings file. Format is used to create the matrix for SVD
svd.load_data(filename='ratings_complete.csv', sep=',' , format={'col':0, 'row':1,  'value':2, 'ids':int})
#Now, lets compute the SVD. Formula is M = U(Sigma)V^T
k = 100
svd.compute(k=k, min_values=10, pre_normalize=None, mean_center=True, post_normalize=True, savefile='movielens_complete')

print("Model Computed and Created")
开发者ID:tbarnes94,项目名称:Movie-Recommendation-Project,代码行数:23,代码来源:svd.py

示例14: SVD

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
import recsys.algorithm
recsys.algorithm.VERBOSE = True

from recsys.algorithm.factorize import SVD
svd = SVD()
svd.load_data(filename='ml-1m/ratings.dat', sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
开发者ID:lfmejia88,项目名称:UCL-IRDM-Recomm-,代码行数:8,代码来源:TEST_AGNES.py

示例15: SVDloadData

# 需要导入模块: from recsys.algorithm.factorize import SVD [as 别名]
# 或者: from recsys.algorithm.factorize.SVD import load_data [as 别名]
def SVDloadData():
    svd = SVD()
    recsys.algorithm.VERBOSE = True
    dat_file = 'ratings.dat'
    svd.load_data(filename=dat_file, sep='::', format={'col':0, 'row':1, 'value':2, 'ids': int})
    return svd
开发者ID:derZukunft,项目名称:GADataScience2013,代码行数:8,代码来源:rec.py


注:本文中的recsys.algorithm.factorize.SVD.load_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。