本文整理汇总了Python中lib.util.Util.time_to_str方法的典型用法代码示例。如果您正苦于以下问题:Python Util.time_to_str方法的具体用法?Python Util.time_to_str怎么用?Python Util.time_to_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.util.Util
的用法示例。
在下文中一共展示了Util.time_to_str方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: infer
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import time_to_str [as 别名]
def infer(self, params):
window = {'tweets':[], 'start':0} # storing tweets
""" User distribution updating """
for tweet in self.tweets.stream():
if type(tweet) == type({}) and 'timestamp' in tweet:
current_time = Util.str_to_unixtime(Util.time_to_str(tweet['timestamp']))
window['tweets'].append(tweet)
if current_time - window['start'] > params['window_size']:
if params['tl']:
""" use tl-words """
tlwords = self.extract_local_words_(window['tweets'], params)
else:
""" dont use tl-words """
tlwords = Words()
self.update_user_distributions(window['tweets'], tlwords, params)
window = {'tweets':[], 'start':current_time}
""" Location prediction using user distribution """
for user in self.users.iter():
if user['location_point'] == None:
""" unlabeled user """
if user['id'] in self.user_distributions and len(self.user_distributions[user['id']]) > 0:
inferred_city = self.predict(self.user_distributions[user['id']], params)
inferred_location = self.model.means_[inferred_city]
user['location_point'] = inferred_location
else:
if params['default']:
""" no clues """
""" predict using prior """
inferred_city = self.predict({}, params)
inferred_location = self.model.means_[inferred_city]
user['location_point'] = inferred_location