Skip to content

Commit

Permalink
fix HPF
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Jan 21, 2025
1 parent 4a8d383 commit a7c4aab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lenskit-hpf/lenskit/hpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ def train(self, data: Dataset, options: TrainingOptions = TrainingOptions()):
if hasattr(self, "item_features_") and not options.retrain:
return

log = data.interaction_matrix(format="pandas", field="rating")
log = data.interactions().pandas()
if "rating" not in log.columns:
log["rating"] = 1.0

log = log.rename(
columns={
"user_num": "UserId",
"item_num": "ItemId",
"rating": "Count",
}
)
)[["UserId", "ItemId", "Count"]]

hpf = hpfrec.HPF(self.config.features, reindex=False, **self.config.__pydantic_extra__) # type: ignore

Expand Down
4 changes: 4 additions & 0 deletions lenskit/lenskit/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,10 @@ def is_interaction(self) -> bool:
"""
return self.schema.interaction

@property
def attribute_names(self) -> list[str]:
return [c for c in self._table.column_names if c not in self._link_cols]

def count(self):
if "count" in self._table.column_names:
raise NotImplementedError()
Expand Down

0 comments on commit a7c4aab

Please sign in to comment.