Skip to content

Add EASE scorer#1012

Merged
mdekstrand merged 33 commits intolenskit:mainfrom
mdekstrand:feature/942-ease
Feb 23, 2026
Merged

Add EASE scorer#1012
mdekstrand merged 33 commits intolenskit:mainfrom
mdekstrand:feature/942-ease

Conversation

@mdekstrand
Copy link
Copy Markdown
Member

@mdekstrand mdekstrand commented Feb 21, 2026

This adds an implementation of EASE, along with supporting changes to matrix relationship sets and co-occurrence counting.

It could be further sped up (a little) by directly counting into a dense matrix, instead of counting into a sparse matrix and then making it dense.

Closes #942.

@mdekstrand mdekstrand added this to the 2026.1 milestone Feb 21, 2026
@mdekstrand mdekstrand self-assigned this Feb 21, 2026
@mdekstrand mdekstrand added components LensKit recommendation components data Data management support. labels Feb 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 93.43066% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.34%. Comparing base (d64593d) to head (6f55705).
⚠️ Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
src/lenskit/knn/ease.py 93.91% 7 Missing ⚠️
src/accel/data/pairs/dense.rs 88.88% 6 Missing ⚠️
src/accel/data/pairs/symmetric.rs 90.00% 3 Missing ⚠️
src/accel/data/cooc.rs 97.50% 1 Missing ⚠️
src/lenskit/training.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1012      +/-   ##
==========================================
+ Coverage   89.27%   89.34%   +0.07%     
==========================================
  Files         221      223       +2     
  Lines       15292    15534     +242     
==========================================
+ Hits        13652    13879     +227     
- Misses       1640     1655      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/lenskit/knn/ease.py Outdated
mat = spla.inv(cooc, assume_a="pos")
log.info("inverted co-occurrance matrix in %s", timer)

mat /= np.diag(mat)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we missing a minus sign here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yes!

Comment thread src/lenskit/knn/ease.py Outdated
q_vec[q_good] = 1.0

_log.debug("multiplying matrix for %d items", np.sum(q_ok))
scores = self.weights @ q_vec
Copy link
Copy Markdown
Contributor

@samiravaez samiravaez Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this match the paper's s=xB scoring formula? Since we compute Bx here, I was wondering if the orientation is correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, but since B is symmetric, it doesn't matter.

Copy link
Copy Markdown
Contributor

@samiravaez samiravaez Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If P is symmetric, dividing it by its diagonal as in B = P / (-np.diag(P)) in the paper should break symmetry. I ran a quick test and it wasn’t symmetric. Am I missing something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right — I'll check again tomorrow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you're right. Fixed.

@mdekstrand mdekstrand merged commit d69c5aa into lenskit:main Feb 23, 2026
40 checks passed
@mdekstrand mdekstrand deleted the feature/942-ease branch February 23, 2026 21:11
mdekstrand added a commit to mdekstrand/lkpy that referenced this pull request Feb 24, 2026
Comment thread src/lenskit/training.py
:attr:`environment`, then in :attr:`os.environ`.
"""
if name in self.environment:
return name
Copy link
Copy Markdown
Contributor

@samiravaez samiravaez Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should return the value here as self.environment[name], right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in flight in #1018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components LensKit recommendation components data Data management support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add EASE

2 participants