Exemplo n.º 1
0
class Recommender(Base):
	""" 
	Inherits from Base-Object

	Returns a nested dictionary of budgets each with housing recommendation
	"""
	def __init__(self):
		
		self.budgeting = Budgeter() # predict() returns max, mean, min budgets 
		self.lodging = Lodger() # predict() returns three lodging options that housing prediction 
		self.statecluster = StateCluster() # predict() returns list of states with clustering 1-5

	def recommend(self, user_salary, rent=None, own=None, household_size=None ):
		user_recommendations = {"timestamp": datetime.datetime.now().isoformat(' ')}		

		budgets = self.budgeting.predict(user_salary)
		
		for b in budgets.keys():
			# print b
			housing = budgets[b]['housing']
			budgets[b]['lodging'] = self.lodging.predict(housing) # returns dictionary of recommendations
		
		user_recommendations["budgeting"] = budgets	
		user_recommendations['statecluster'] = self.statecluster.predict(user_salary)

		return user_recommendations
Exemplo n.º 2
0
	def __init__(self):
		
		self.budgeting = Budgeter() # predict() returns max, mean, min budgets 
		self.lodging = Lodger() # predict() returns three lodging options that housing prediction 
		self.statecluster = StateCluster() # predict() returns list of states with clustering 1-5
Exemplo n.º 3
0
		for b in budgets.keys():
			# print b
			housing = budgets[b]['housing']
			budgets[b]['lodging'] = self.lodging.predict(housing) # returns dictionary of recommendations
		
		user_recommendations["budgeting"] = budgets	
		user_recommendations['statecluster'] = self.statecluster.predict(user_salary)

		return user_recommendations

		

if __name__ == '__main__':
	import pprint
	

	main = Recommender()
	pprint.pprint(main.recommend(40000))

	lodge = Lodger()
	assert lodge.predict(1000, preferences="this")[1]['type'] == '1BR'
	print 'test lodger passed'

	budget = Budgeter()
	assert budget.predict(40000)['max']['housing'] == 6000.0
	print 'test budget passed'

	state = StateCluster()
	assert state.predict(1000)[u'District of Columbia'] == 1
	print 'test state passed'