Skip to content

Commit

Permalink
Slightly modified CoClustering algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Dec 28, 2016
1 parent 1a7a2e8 commit 4e160a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 2 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
TODO
====

* Better document SlopeOne and CoClustering algorithms.
* Make coclustering fully complient with paper's prediction
* Make cleaner paper citations
* Check out the yelp dataset
* See if we could compute similarity on the fly (see issue #3)
* configure entrypoints to use surprise directly from command line
* make a 'contribute' file

Maybe, Maybe not
----------------
Expand Down
15 changes: 11 additions & 4 deletions surprise/prediction_algorithms/co_clustering.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class CoClustering(AlgoBase):
where :math:`\\overline{C_{ui}}` is the average rating of co-cluster
:math:`C_{ui}`, :math:`\\overline{C_u}` is the average rating of
:math:`u`'s cluster, and :math:`\\overline{C_i}` is the averate rating of
:math:`i`'s cluster.
:math:`i`'s cluster. If the user is unknown, the prediction is
:math:`\hat{r}_{ui} = \\mu_i`. If the item is unkown, the prediction is
:math:`\hat{r}_{ui} = \\mu_u`. If both the user and the item are unknown,
the prediction is :math:`\hat{r}_{ui} = \\mu`.
Clusters are assigned using a straightforward optimization method, much
like k-means.
Expand Down Expand Up @@ -223,10 +226,14 @@ class CoClustering(AlgoBase):

def estimate(self, u, i):

# Note: This is not exactly what the author's paper recommend but oh
# well...
if not (self.trainset.knows_user(u) and self.trainset.knows_item(i)):
raise PredictionImpossible('User and/or item is unkown.')
return self.trainset.global_mean

if not self.trainset.knows_user(u):
return self.cltr_i[i]

if not self.trainset.knows_item(i):
return self.cltr_u[u]

# I doubt cdefing makes any difference here as cython has no clue about
# arrays self.stuff... But maybe?
Expand Down

0 comments on commit 4e160a7

Please sign in to comment.