Item-item similarity using adjusted cosine / Pearson correlation I'm following a lecture that explains how to calculate item-item similarities using adjusted cosine distance (or Pearson correlation). I tried implementing this and have not gotten the same results.
This reproduces my experiment:
import pandas as pd

df = pd.read_json("./movie-ratings.json")

# This is how the lecture did it:
# Subtract the mean movie score from each movie column
item_mean_subtracted = df.sub(df.mean(axis=0), axis=1)

# Compute similarities with Pearson correlation
similar_item_matrix_1 = item_mean_subtracted.fillna(0).corr(method="pearson")

# This is how I think it should be done:
# Remove user rating bias by subtracting the mean user score from each user row.
user_mean_subtracted = df.sub(df.mean(axis=1), axis=0)

# Compute similarities again
similar_item_matrix_2 = user_mean_subtracted.fillna(0).corr(method="pearson")

Why does the lecture subtract the mean movie rating and not the mean user rating? I thought  Also, I thought part of Pearson correlation was subtracting the mean. Why do I need to subtract the mean before doing Pearson correlation to get the numbers to look right?
 A: *

*Why does the lecture subtract the mean movie rating and not the mean user rating?


There are two questions you could ask: 
a) How much does Mike Miller like the "Lord of the Rings" relative to the other users?
b) How much does Mike Miller like the "Lord of the Rings" relative to the other movies he rated?
If you are interested in a), you would center using mean movie score. If you are interested in b), you would center using the mean user score. Therefore I conclude, that your lecturer is interested in a). Yet both are valid questions and both could potentially be input further processing. 


*Why do I need to subtract the mean before doing Pearson correlation to get the numbers to look right?


Simply because that's what your lecturer did. Because your definition of "right" is "what my lecturer did". I assume he gave a great argument in the lecture, which we both missed. In general, both potentially are of (research) interest. Yet when building a recommender system, you are probably being taught a very specific way (features, classifier, training) of how someone did it. 
This does not mean, that it is the (only) right way.
Best way to go would be to use your input and his input for a recommender system and compare the results. . 
