Ejemplo n.º 1
0
        random.shuffle(dataset)

        combinations = Utils.break_dataset_in_folds(dataset, 5)

        for combination in combinations:

            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)