social_model_stanford = CorrectSocialModelStanford()
			if user in network:
				social_model_ours = SimpleSocialModel(datasets, network[user], user)
			
			train = combination['train']
			test = combination['test'] 
			#---------------------------------------------------------------------------
			model = StanfordModel()
			model.train(train, number_of_iterations = 10)

			if model.parameters != None:
				correct = 0
				for check_in in test:
					real_venue = check_in["venue_id"]
					time = check_in["date"]
					predicted_venue = model.predict(time, train + test)
					if real_venue == predicted_venue:
						correct += 1
				results_stanford.append(float(correct)/len(test))
				#------------
				if user in network:
					social_model_stanford.fit_model(model, network[user], datasets)
					correct = 0
					for check_in in test:
						real_venue = check_in["venue_id"]
						date = check_in["date"]
						latitude = check_in["latitude"]
						longitude = check_in["longitude"]

						spatio_temporal_p = model.predict(time, train + test, True)
						social_p = social_model_stanford.get_probabilities(network[user], datasets, date, train + test)
			combinations = Utils.break_dataset_in_folds(dataset, 5)

			for combination in combinations:

				train = combination['train']
				test = combination['test'] 

				#---------------------------------------------------------------------------
				model = StanfordModel()
				model.train(train, number_of_iterations = 10)
				if model.parameters != None:
					correct = 0
					for check_in in test:
						real_venue = check_in["venue_id"]
						time = check_in["date"]
						predicted_venue = model.predict(time, train + test)
						if real_venue == predicted_venue:
							correct += 1
					results_stanford[day].append(float(correct)/len(test))
				#---------------------------------------------------------------------------
				all_check_ins = train + test
				all_venues = [x["venue_id"] for x in all_check_ins]
				n_values = Counter(all_venues)
				coordinates = {}
				for venue in all_venues:
					latitude = np.median([x["latitude"] for x in all_check_ins if x["venue_id"] == venue])
					longitude = np.median([x["longitude"] for x in all_check_ins if x["venue_id"] == venue])
					coordinates[venue] = (latitude, longitude)

				model = NCGModel(n_values, coordinates)
				model.train(train, number_of_iterations = 10)
Ejemplo n.º 3
0
            if user in network:
                social_model_ours = SimpleSocialModel(datasets, network[user],
                                                      user)

            train = combination['train']
            test = combination['test']
            #---------------------------------------------------------------------------
            model = StanfordModel()
            model.train(train, number_of_iterations=10)

            if model.parameters != None:
                correct = 0
                for check_in in test:
                    real_venue = check_in["venue_id"]
                    time = check_in["date"]
                    predicted_venue = model.predict(time, train + test)
                    if real_venue == predicted_venue:
                        correct += 1
                results_stanford.append(float(correct) / len(test))
                #------------
                if user in network:
                    social_model_stanford.fit_model(model, network[user],
                                                    datasets)
                    correct = 0
                    for check_in in test:
                        real_venue = check_in["venue_id"]
                        date = check_in["date"]
                        latitude = check_in["latitude"]
                        longitude = check_in["longitude"]

                        spatio_temporal_p = model.predict(
            combinations = Utils.break_dataset_in_folds(dataset, 5)

            for combination in combinations:

                train = combination["train"]
                test = combination["test"]

                # ---------------------------------------------------------------------------
                model = StanfordModel()
                model.train(train, number_of_iterations=10)
                if model.parameters != None:
                    correct = 0
                    for check_in in test:
                        real_venue = check_in["venue_id"]
                        time = check_in["date"]
                        predicted_venue = model.predict(time, train + test)
                        if real_venue == predicted_venue:
                            correct += 1
                    results_stanford[day].append(float(correct) / len(test))
                    # ---------------------------------------------------------------------------
                all_check_ins = train + test
                all_venues = [x["venue_id"] for x in all_check_ins]
                n_values = Counter(all_venues)
                coordinates = {}
                for venue in all_venues:
                    latitude = np.median([x["latitude"] for x in all_check_ins if x["venue_id"] == venue])
                    longitude = np.median([x["longitude"] for x in all_check_ins if x["venue_id"] == venue])
                    coordinates[venue] = (latitude, longitude)

                model = NCGModel(n_values, coordinates)
                model.train(train, number_of_iterations=10)