本文整理汇总了Python中library.file_io.FileIO.writeToFile方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.writeToFile方法的具体用法?Python FileIO.writeToFile怎么用?Python FileIO.writeToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.file_io.FileIO
的用法示例。
在下文中一共展示了FileIO.writeToFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeHashtagsFile
# 需要导入模块: from library.file_io import FileIO [as 别名]
# 或者: from library.file_io.FileIO import writeToFile [as 别名]
def writeHashtagsFile():
hashtags = []
for hashtagObject in FileIO.iterateJsonFromFile('/mnt/chevron/kykamath/data/geo/hashtags/analysis/all_world/2_11/hashtagsWithoutEndingWindow'):
print hashtagObject.keys()
exit()
hashtags.append(hashtagObject['h'])
hashtags=sorted(hashtags)
for h in hashtags: FileIO.writeToFile(unicode(h).encode('utf-8'), 'hashtags')
示例2: _write_json_output
# 需要导入模块: from library.file_io import FileIO [as 别名]
# 或者: from library.file_io.FileIO import writeToFile [as 别名]
def _write_json_output(cls, output_filename, key, mr_job, runner):
for line in runner.stream_output():
key, value = mr_job.parse_output_line(line)
if hasattr(mr_job, 'output_writer'):
mr_job.output_writer(key, value, output_filename)
else:
key = str(key)
value = str(value)
FileIO.writeToFile(key + ' ' + value, output_filename)
示例3: writeInputFileForFIMahout
# 需要导入模块: from library.file_io import FileIO [as 别名]
# 或者: from library.file_io.FileIO import writeToFile [as 别名]
def writeInputFileForFIMahout(minLocationsTheUserHasCheckedin, minUniqueUsersCheckedInTheLocation):
[
FileIO.writeToFile(
" ".join([i.replace(" ", "_") for i in t]),
locationsFIMahoutInputFile % (minLocationsTheUserHasCheckedin, minUniqueUsersCheckedInTheLocation),
)
for t in locationTransactionsIterator(minLocationsTheUserHasCheckedin, minUniqueUsersCheckedInTheLocation)
]
示例4: compare_zones_with_test_set
# 需要导入模块: from library.file_io import FileIO [as 别名]
# 或者: from library.file_io.FileIO import writeToFile [as 别名]
def compare_zones_with_test_set(ltuo_model_id_and_hashtag_tag, test_model_id):
output_file = fld_results%GeneralMethods.get_method_id()+'results.csv'
GeneralMethods.runCommand('rm -rf %s'%output_file)
mf_model_id_to_misrank_accuracies = defaultdict(list)
mf_model_id_to_mf_location_to_zone_id = {}
for model_id, hashtag_tag in ltuo_model_id_and_hashtag_tag:
no_of_zones, ltuo_location_and_influence_score_and_zone_id = Experiments.get_location_with_zone_ids(model_id, hashtag_tag)
locations, influence_scores, zone_ids = zip(*ltuo_location_and_influence_score_and_zone_id)
mf_model_id_to_mf_location_to_zone_id[model_id] = dict(zip(locations, zone_ids))
ltuo_hashtag_and_ltuo_location_and_occurrence_time = Experiments.load_ltuo_hashtag_and_ltuo_location_and_occurrence_time()
for hashtag_count, (hashtag, ltuo_location_and_occurrence_time) in\
enumerate(ltuo_hashtag_and_ltuo_location_and_occurrence_time):
# print hashtag_count
# if hashtag_count==10: break;
ltuo_location_and_occurrence_time = sorted(ltuo_location_and_occurrence_time, key=itemgetter(1))
# hashtag_zone_ids = [for ltuo_location, _ in ltuo_location_and_occurrence_time]
locations = reduce(InfluenceAnalysis._to_locations_based_on_first_occurence, zip(*ltuo_location_and_occurrence_time)[0], [])
# mf_location_to_hashtags_location_rank = dict(zip(locations, range(len(locations))))
# for hashtag_count, (hashtag, ltuo_location_and_pure_influence_score) in \
# enumerate(Experiments.load_ltuo_test_hashtag_and_ltuo_location_and_pure_influence_score(test_model_id)):
# locations = zip(*ltuo_location_and_pure_influence_score)[0]
for model_id, mf_location_to_zone_id in \
mf_model_id_to_mf_location_to_zone_id.iteritems():
models_location_rank = [mf_location_to_zone_id[location] for location in locations if location in mf_location_to_zone_id]
# print models_location_rank
if len(models_location_rank)>1:
misrank_accuracies = map(
InfluenceAnalysis._get_rank_accuracy,
zip(models_location_rank, [models_location_rank]*len(models_location_rank))
)
mf_model_id_to_misrank_accuracies[model_id].append(np.mean(misrank_accuracies))
#Random model
# random_location_rank = range(len(locations))
random_location_rank = models_location_rank
random.shuffle(random_location_rank)
random_misrank_accuracies = map(
InfluenceAnalysis._get_rank_accuracy,
zip(random_location_rank, [random_location_rank]*len(random_location_rank))
)
data = ', '.join([str(hashtag_count), str(len(ltuo_location_and_occurrence_time)), str(np.mean(misrank_accuracies)), str(np.mean(random_misrank_accuracies)), str(len(models_location_rank))])
FileIO.writeToFile(data, output_file)
示例5: writeARFFForClustering
# 需要导入模块: from library.file_io import FileIO [as 别名]
# 或者: from library.file_io.FileIO import writeToFile [as 别名]
def writeARFFForClustering(data, relationName):
keyToIdMap = {}
fileName = '/tmp/'+relationName+'.arff'
os.system('rm -rf %s'%fileName)
for docId in sorted(data):
docVector = data[docId]
for k, v in docVector.iteritems():
if k not in keyToIdMap: keyToIdMap[k]=len(keyToIdMap)
FileIO.writeToFile(ARFF.getRelationLine(relationName), fileName)
for attributeName in keyToIdMap: FileIO.writeToFile(ARFF.getAttributeLine(attributeName), fileName)
FileIO.writeToFile('@data', fileName)
for d in data.iteritems(): FileIO.writeToFile(ARFF.getDataLine(d, keyToIdMap), fileName)
return fileName
示例6: output_writer
# 需要导入模块: from library.file_io import FileIO [as 别名]
# 或者: from library.file_io.FileIO import writeToFile [as 别名]
def output_writer(self, key, value, output_filename):
print 'Writing data for ', key, ' to ', output_filename + '_' + key
FileIO.writeToFile(encode({'uids':value}), output_filename + '_' + key)