Beispiel #1
0
def getAverageMoviesRatings(udata_array):

    #summ of ratings, rating count
    #iterator = movieId
    array = np.zeros(shape=(MOVIE_COUNT, 2), dtype=int)

    for i in range(len(udata_array)):
        movieId = udata_array[i, 1]
        rating = udata_array[i, 2]
        normalized_rating = common.getQuantizedRating(rating)

        array[movieId - 1, 1] += 1
        array[movieId - 1, 0] += normalized_rating

    arrayWithAverageRatings = np.zeros(shape=(MOVIE_COUNT, 1), dtype=int)
    for i in range(MOVIE_COUNT):
        ratingCount = array[i, 1]
        ratingSumm = array[i, 0]

        avg = 0.0
        if (ratingCount > 0):
            avg = float(ratingSumm) / ratingCount
        if (avg > 0.5):
            arrayWithAverageRatings[i] = 1
    return arrayWithAverageRatings
Beispiel #2
0
def getQuantizedAverageRecomendationPoint(arrayWithAverageRatings, user_rating,
                                          movieId):
    normalized_user_rating = common.getQuantizedRating(user_rating)
    if (normalized_user_rating == int(arrayWithAverageRatings[movieId - 1])):
        return 1
    else:
        return 0
def getNormalizedAvgRatingPotinFromSimilarTaste(ratingsCorelation3, ratingsCorelation2, ratingsCorelation1, rating):
    normalizedOtherRating = getNormalizedAveragedRatingFromSimilarTaste(ratingsCorelation3, ratingsCorelation2, ratingsCorelation1, rating)
    normalizedRating = common.getQuantizedRating(rating)
    #print(str(normalizedRating) + " " + str(normalizedOtherRating))
    if(normalizedOtherRating == normalizedRating):
        return 1
    else:
        return 0
def getNormalizedAveragedRatingFromSimilarTaste(ratingsCorelation3, ratingsCorelation2, ratingsCorelation1, rating):
    bestUsersRatings = getBestFitSimilarUsersDictionary(ratingsCorelation3, ratingsCorelation2, ratingsCorelation1)
    summ = 0
    count = len(bestUsersRatings)
    for i in range(count):
        summ += bestUsersRatings[i]        
     
    avgRating = float(summ)/float(count)
    return common.getQuantizedRating(avgRating)
def getRandomRSPrecisionRecall(udata_array):
    count = 0
    summ = 0
    
    finalCount = len(udata_array)
    
    precisionList = []
    recallList = []
    
    for row in udata_array:
        user_rating = common.getQuantizedRating(row[2])
        system_rating = common.getQuantizedRating(random.randint(1, 5))
        
        count += 1
        if(user_rating == system_rating):
            summ += 1
        precisionList.append(summ/count)
        recallList.append(summ/finalCount)
    
    return common.PrecisionRecallModel(precisionList, recallList)
Beispiel #6
0
def getNormalizedAvgRatingPotinFromSimilarTaste(ratingsCorelation3,
                                                ratingsCorelation2,
                                                ratingsCorelation1, rating):
    normalizedOtherRating = getNormalizedAveragedRatingFromSimilarTaste(
        ratingsCorelation3, ratingsCorelation2, ratingsCorelation1, rating)
    normalizedRating = common.getQuantizedRating(rating)
    #print(str(normalizedRating) + " " + str(normalizedOtherRating))
    if (normalizedOtherRating == normalizedRating):
        return 1
    else:
        return 0
Beispiel #7
0
def getRandomRSPrecisionRecall(udata_array):
    count = 0
    summ = 0

    finalCount = len(udata_array)

    precisionList = []
    recallList = []

    for row in udata_array:
        user_rating = common.getQuantizedRating(row[2])
        system_rating = common.getQuantizedRating(random.randint(1, 5))

        count += 1
        if (user_rating == system_rating):
            summ += 1
        precisionList.append(summ / count)
        recallList.append(summ / finalCount)

    return common.PrecisionRecallModel(precisionList, recallList)
Beispiel #8
0
def getNormalizedAveragedRatingFromSimilarTaste(ratingsCorelation3,
                                                ratingsCorelation2,
                                                ratingsCorelation1, rating):
    bestUsersRatings = getBestFitSimilarUsersDictionary(
        ratingsCorelation3, ratingsCorelation2, ratingsCorelation1)
    summ = 0
    count = len(bestUsersRatings)
    for i in range(count):
        summ += bestUsersRatings[i]

    avgRating = float(summ) / float(count)
    return common.getQuantizedRating(avgRating)
Beispiel #9
0
def getQuantizedList(mList):
    qList = []
    for i in range(len(mList)):
        qList.append(common.getQuantizedRating(mList[i]))
    return qList
def getQuantizedList(mList):
    qList = []
    for i in range(len(mList)):
        qList.append(common.getQuantizedRating(mList[i]))
    return qList