• 大小: 19.24MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-26
  • 语言: 其他
  • 标签: 智能推荐  

资源简介

利用机器学习进行歌曲推荐。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

资源截图

代码片段和文件信息

import math
import sys

def main(p_train p_output):
    infile = open(p_train)
    infile.readline()

    art_uid_score = {}
    uid_score = {}


    for line in infile:
        artid iid uid score time = line.strip().split(‘‘)
        key = artid + ‘\t‘ + uid

        if key not in art_uid_score:
            art_uid_score[key] = []

        art_uid_score[key].append(float(score) )


    outfile = open(p_output ‘w‘)
    for key in art_uid_score:

        max_score = max(art_uid_score[key])
        min_score = min(art_uid_score[key])
        total = 0
        for member in art_uid_score[key]:
            total += member

        #(artid uid) ave_score min_score max_score score_num
        outfile.write(key + ‘\t‘ + str(float(total)/len(art_uid_score[key])) + ‘\t‘ + str(min_score) + ‘\t‘+str(max_score) + ‘\t‘ + str(len(art_uid_score[key])) + ‘\n‘)

    outfile.close()
    infile.close()


if __name__ == ‘__main__‘:
    import sys
    if len(sys.argv) < 3:
        print ‘ train output‘
        exit(-1)
    p_train = sys.argv[1]
    p_output = sys.argv[2]

    main(p_train p_output)




 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\
     文件         484  2014-07-23 18:06  codes_of_innovations_for_emi-master\README.md
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\
     文件         696  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\README.md
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\bin\
     文件        1600  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\bin\run_predict_all.sh
     文件        2273  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\bin\run_predict_validation.sh
     文件         697  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\bin\run_prepare.sh
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\
     文件         239  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\mapping_2th_column.txt
     文件         213  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\mapping_3th_column.txt
     文件     2101541  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\rec_log_test.group
     文件     3318735  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\rec_log_train.group
     文件     2101571  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\test_5_columns.csv
     文件     3770604  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users.new.csv
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\
     文件          20  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\map_gender.map
     文件         390  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\map_list_back.map
     文件         396  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\map_list_own.map
     文件         376  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\map_music_value.map
     文件          84  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\map_region_value.map
     文件         418  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\users_file_meta\map_working_status.map
     文件     7723091  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\words.mid.csv
     文件     3204334  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\words.new.csv
     文件    19736846  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\mid_data\words_process.csv
     目录           0  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\raw_data\
     文件        3493  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\raw_data\UserKey.csv
     文件     1849976  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\raw_data\test.csv
     文件     3318765  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\raw_data\train.csv
     文件     8608150  2014-07-23 18:06  codes_of_innovations_for_emi-master\code_of_innovations\data\raw_data\users.csv
............此处省略61个文件信息

评论

共有 条评论

相关资源