Example #1
0
 def __init__(self):
     super(Window, self).__init__()
     animes = readDataframe.Animes()
     self.itemBased = WindowFiltering(
         CollaborativeFiltering(animes.animes, animes.rating))
     self.contentBased = WindowFiltering(ContentFiltering(animes.animes))
     self.addTab(self.itemBased, "Pessoas tambem assistiram")
     self.addTab(self.contentBased, "Porque voce assistiu")
Example #2
0
    def getUserMovies(self, method, userId, noMovies):

        if method == "Collaborative":
            recommender = CollaborativeFiltering(self._ratingsFilename, self._trainSetPath)
            # recommender.train()
            return recommender.getImpersonatedUserMovies(userId, noMovies)

        elif method == "Content":
            recommender = ContentFiltering(self._ratingsFilename, self._tagsFilename, self._trainSetPath)
            # recommender.train()
            return recommender.getImpersonatedUserMovies(userId, noMovies)

        elif method == "Hybrid":
            collaborativeTrainer = CollaborativeFiltering(self._ratingsFilename, self._trainSetPath)
            # collaborativeTrainer.train()
            collaborativeMovies = collaborativeTrainer.getImpersonatedUserMovies(userId, noMovies*2)
            contentTrainer = ContentFiltering(self._ratingsFilename, self._tagsFilename, self._trainSetPath)
            # contentTrainer.train()
            contentMovies = contentTrainer.getImpersonatedUserMovies(userId, noMovies*2)
            return self._hybridise(noMovies, collaborativeMovies, contentMovies)

        else:
            pass
Example #3
0
import pandas as pd
a = pd.read_csv("movieLens.csv")

from CollaborativeFiltering import CollaborativeFiltering

b= CollaborativeFiltering(formatizer={'user': '******', 'item': 'movieName', 'value': 'rating'})

from sklearn.cross_validation import train_test_split
from sklearn.metrics import mean_squared_error

x,y = train_test_split(a, test_size= 0.1)

x.reset_index(inplace=True)
y.reset_index(inplace=True)

b.fit(data=x)
m= y['rating'].tolist()
n= b.predict(X=y)
print mean_squared_error(m, n)
out = []
true= []
for i in range(len(m)):
    print m[i], n[i]
    if n[i]!=2.5:
        out.append(n[i])
        true.append(m[i])
print mean_squared_error(true, out)

"""

bb=transformPrefs(ratings)
Example #4
0
            baseline_recommend = BaselineRecommendations('arbitrary')
            baseline_recommend.run_baseline()


    #***************Item-Item Collaborative Filtering Recommendation***************
    collab_filt = raw_input("Do you want to run the collaborative filtering recommendation? (yes or no) ")
    while collab_filt != 'yes' and collab_filt != 'no':
        collab_filt = raw_input("Do you want to run the collaborative filtering recommendation? (yes or no) ")
    if collab_filt == 'yes':
        sample_type = raw_input("Do you want to run the randomly sampled data, arbitrarily sampled data or both? (r, a, b) ")
        while sample_type != 'r' and sample_type != 'a' and sample_type != 'b':
            sample_type = raw_input("Do you want to run the randomly sampled data, arbitrarily sampled data or both? (r, a, b) ")
        print "Note: this is a fairly time consuming process--please allow for approximately 2+ hours to calculate RMSE on a single dataset."
        if sample_type == 'r':
            print "Calculating RMSE for random dataset split."
            collab_recommend = CollaborativeFiltering()
            collab_recommend.collaborative_filter()
        elif sample_type == 'a':
            print "Calculating RMSE for arbitrary dataset split."
            collab_recommend = CollaborativeFiltering(dataset='arbitrary')
            collab_recommend.collaborative_filter()
        elif sample_type == 'b':
            print "Calculating RMSE for random dataset split."
            collab_recommend = CollaborativeFiltering()
            collab_recommend.collaborative_filter()
            print "Calculating RMSE for arbitrary dataset split."
            collab_recommend = CollaborativeFiltering(dataset='arbitrary')
            collab_recommend.collaborative_filter()


    #***************Latent Factor Model Recommendation***************
Example #5
0
from CollaborativeFiltering import CollaborativeFiltering

file_path = "21B_tag_views_dataset.csv"

cf = CollaborativeFiltering()

cf.load_data(file_path)

print("data loaded")

current_tag_id = "ff0d3fb21c00bc33f71187a2beec389e9eff5332"

similar_items = cf.similar_items(current_tag_id)

print("Users that viewed \"" + cf.products[current_tag_id] + "\" also viewed:")
print(similar_items)
Example #6
0
import pandas as pd

from CollaborativeFiltering import CollaborativeFiltering

if __name__ == '__main__':

    ratings = pd.read_csv('./ml-1m/ratings.dat',
                          engine='python',
                          sep='::',
                          names=['user_id', 'movie_id', 'rating', 'timestamp'])

    collaborative_filtering = CollaborativeFiltering(ratings)

    user_id = 1
    similarity_user_count = 5
    recommend_user_count = 5

    result = collaborative_filtering.recommend_item(user_id,
                                                    similarity_user_count,
                                                    recommend_user_count)

    print(result)