Created
August 21, 2012 19:11
-
-
Save marcelcaraciolo/3418446 to your computer and use it in GitHub Desktop.
regularized correlation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def regularized_correlation(size, dot_product, rating_sum, \ | |
rating2sum, rating_norm_squared, rating2_norm_squared, | |
virtual_cont, prior_correlation): | |
''' | |
The Regularized Correlation between two vectors A, B | |
RegularizedCorrelation = w * ActualCorrelation + (1 - w) * PriorCorrelation | |
where w = # actualPairs / (# actualPairs + # virtualPairs). | |
''' | |
unregularizedCorrelation = correlation(size, dot_product, rating_sum, \ | |
rating2sum, rating_norm_squared, rating2_norm_squared) | |
w = size / float(size + virtual_cont) | |
return w * unregularizedCorrelation + (1.0 - w) * prior_correlation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment