<commit_before>import numpy as np

def cosine(a, b):
    return np.dot(a, b)/(np.linalg.norm(a)*np.linalg.norm(b))

def cosineMatrix(ratingMatrix, noitems):
    sim = np.zeros((noitems, noitems))
    for i in xrange(noitems):
        for j in xrange(i,noitems):
            sim[i][j] = cosine(ratingMatrix[:,i],ratingMatrix[:,j])
            sim[j][i] = sim[i][j]
    return sim
<commit_msg>pearson correlation similarity function added<commit_after>import numpy as np

def cosine(a, b):
    return np.dot(a, b)/(np.linalg.norm(a)*np.linalg.norm(b))

def cosineMatrix(ratingMatrix, noitems):
    sim = np.zeros((noitems, noitems))
    for i in xrange(noitems):
        for j in xrange(i,noitems):
            sim[i][j] = cosine(ratingMatrix[:, i],ratingMatrix[:, j])
            sim[j][i] = sim[i][j]
    return sim

def pearsonCosineMatrix(ratingMatrix, noitems):
    sim = np.zeros((noitems, noitems))
    for i in xrange(noitems):
        for j in xrange(i,noitems):
            sim[i][j] = cosine(ratingMatrix[:, i] - np.mean(ratingMatrix[:, i]),
                ratingMatrix[:, j] - np.mean(ratingMatrix[:, j]))
            sim[j][i] = sim[i][j]
    return sim
{'fraction_non_alphanumeric': 0.16394849785407725, 'fraction_numerical': 0.0, 'mean_word_length': 3.1056338028169015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3675729', 'n_tokens_mistral': 422, 'n_tokens_neox': 423, 'n_words': 93}