本文整理匯總了Python中recommender.Recommender.setBudget方法的典型用法代碼示例。如果您正苦於以下問題:Python Recommender.setBudget方法的具體用法?Python Recommender.setBudget怎麽用?Python Recommender.setBudget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recommender.Recommender
的用法示例。
在下文中一共展示了Recommender.setBudget方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from recommender import Recommender [as 別名]
# 或者: from recommender.Recommender import setBudget [as 別名]
def main():
startTime = datetime(2016,4,30,8)
endTime = datetime(2016,5,1,18)
recom = Recommender()
recom.setTimeInterval(startTime,endTime)
recom.setHabit({"0":90,"1":40,"2":50})
recom.setBudget(1) # allow 1,2,3
travelList = recom.recommend()
print(travelList)
day = 1
travelDict = {}
for _list in travelList:
travelDict[day] = {}
for spot in _list:
travelDict[day][spot.name] = {"coord":spot.coord,"popularity":spot.popularity,"priceLevel":spot.priceLevel,"topic":spot.topicList,"order":spot.order}
day += 1
示例2: post
# 需要導入模塊: from recommender import Recommender [as 別名]
# 或者: from recommender.Recommender import setBudget [as 別名]
def post(self):
json_obj = json_decode(self.request.body)
print('Post data received')
for key in list(json_obj.keys()):
print('key: %s , value: %s' % (key, json_obj[key]))
#response_to_send = {}
#response_to_send['newkey'] = 'hello'
#print('Response to return')
#self.write(json.dumps(response_to_send))
#print('yoooooo')
start_date = json_obj['startDate'].split('-')
end_date = json_obj['endDate'].split('-')
#schedule
startTime = datetime(int(start_date[0]),int(start_date[1]),int(start_date[2]),int(json_obj['startTime']))
endTime = datetime(int(end_date[0]),int(end_date[1]),int(end_date[2]),int(json_obj['endTime']))
recom = Recommender()
recom.setTimeInterval(startTime,endTime)
recom.setHabit(json_obj['like'])
recom.setBudget(json_obj['Budget']) # allow 1,2,3
travelList = recom.recommend()
#print(travelList)
day = 1
travelDict = {}
for _list in travelList:
travelDict[day] = {}
for spot in _list:
#print(spot)
#weather_icon = search_api.get_weather(spot.coord).get('weather')[0].get('icon')
#weather_icon_url = 'http://openweathermap.org/img/w/' + weather_icon + '.png'
weather_icon_url= ''
# print('weather_icon_url = ' + weather_icon_url)
travelDict[day][spot.name] = {"coord":spot.coord,"popularity":spot.popularity,
"priceLevel":spot.priceLevel,"topic":spot.topicList,
"order":spot.order,"ref":spot.ref,
"weather": weather_icon_url}
day += 1
#web_util.write_json(travelDict,"travelList.json")
#self.write(json_encode(travelDict))
self.write(json.dumps(travelDict))