Skip to content

Commit a15879e

Browse files
committed
correct implicit data prep & norm computations
1 parent c754c3a commit a15879e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lenskit/algorithms/als/implicit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4+
import math
45
from typing import Optional
56

67
import numpy as np
@@ -113,6 +114,7 @@ def prepare_data(self, ratings: pd.DataFrame) -> TrainingData:
113114
ratings = ratings[["user", "item"]]
114115

115116
rmat, users, items = sparse_ratings(ratings, torch=True)
117+
rmat.values().multiply_(self.weight)
116118
return TrainingData.create(users, items, rmat)
117119

118120
def initial_params(self, nrows: int, ncols: int) -> torch.Tensor:
@@ -248,4 +250,4 @@ def _train_implicit_cholesky_fanout(
248250
sqerr += torch.dot(diff, diff)
249251
ctx.left[start:end, :] = M
250252

251-
return sqerr.item()
253+
return math.sqrt(sqerr.item())

0 commit comments

Comments
 (0)