algorithms/itemSimilarity.py
def calcSim(item_pair,rating_pairs):
    ''' 
    For each item-item pair, return the specified similarity measure,
    along with co_raters_count
    '''
    sum_xx, sum_xy, sum_yy, sum_x, sum_y, n = (0.0, 0.0, 0.0, 0.0, 0.0, 0)
    
    for rating_pair in rating_pairs:
        sum_xx += np.float(rating_pair[0]) * np.float(rating_pair[0])
        sum_yy += np.float(rating_pair[1]) * np.float(rating_pair[1])
        sum_xy += np.float(rating_pair[0]) * np.float(rating_pair[1])
        # sum_y += rt[1]
        # sum_x += rt[0]
        n += 1

    cos_sim = cosine(sum_xy,np.sqrt(sum_xx),np.sqrt(sum_yy))

    return item_pair, (cos_sim,n)
 
    For each item-item pair, return the specified similarity measure,
    along with co_raters_count
    
For each item-item pair, return the specified similarity measure,
along with co_raters_count
For each item - item pair return the specified similarity measure along with co_raters_count
def calcSim(item_pair,rating_pairs):
    sum_xx, sum_xy, sum_yy, sum_x, sum_y, n = (0.0, 0.0, 0.0, 0.0, 0.0, 0)
    for rating_pair in rating_pairs:
        sum_xx += np.float(rating_pair[0]) * np.float(rating_pair[0])
        sum_yy += np.float(rating_pair[1]) * np.float(rating_pair[1])
        sum_xy += np.float(rating_pair[0]) * np.float(rating_pair[1])
        n += 1
    cos_sim = cosine(sum_xy,np.sqrt(sum_xx),np.sqrt(sum_yy))
    return item_pair, (cos_sim,n)
def calcSim ( item_pair , rating_pairs ) : sum_xx , sum_xy , sum_yy , sum_x , sum_y , n = ( 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0 ) for rating_pair in rating_pairs : sum_xx += np . float ( rating_pair [ 0 ] ) * np . float ( rating_pair [ 0 ] ) sum_yy += np . float ( rating_pair [ 1 ] ) * np . float ( rating_pair [ 1 ] ) sum_xy += np . float ( rating_pair [ 0 ] ) * np . float ( rating_pair [ 1 ] ) n += 1 cos_sim = cosine ( sum_xy , np . sqrt ( sum_xx ) , np . sqrt ( sum_yy ) ) return item_pair , ( cos_sim , n )
For each item-item pair, return the specified similarity measure,
along with co_raters_count
For each item - item pair return the specified similarity measure along with co_raters_count
''' 
    For each item-item pair, return the specified similarity measure,
    along with co_raters_count
    ''' # sum_y += rt[1] # sum_x += rt[0]
item_pair
rating_pairs