Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute retrievability for all states #61

Merged
merged 1 commit into from
Sep 12, 2024
Merged

Conversation

joshdavham
Copy link
Member

Currently, you can only get a card’s retrievability when it’s in the Review state. I thought it would be good enhancement if you could also compute the retrievability for cards in the other states as well.

Changes:

  • Compute retrievability for Learning and Relearning cards the same way it's computed for Review cards
  • New cards have 0 retrievability
    • Rationale: given that new cards have S=0, then for t>0, R(t,S) -> 0 as S -> 0(+)
  • Made the datetime argument optional for the get_retrievability function.
    • If the function is invoked without a given datetime, the datetime defaults to datetime.now(timezone.utc) similar to the Card class's __init__ method or the FSRS class's review_card method.
  • Bump minor version: 3.0.0 -> 3.1.0
  • Add test: test_retrievability to demonstrate this change works

Let me know if this makes sense or if you have questions 👍

Copy link
Member

@L-M-Sherlock L-M-Sherlock left a comment

Choose a reason for hiding this comment

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

LGTM

@joshdavham joshdavham added this pull request to the merge queue Sep 12, 2024
Merged via the queue into main with commit dcbf9ef Sep 12, 2024
5 checks passed
@joshdavham joshdavham deleted the enhance_get_retrievability branch September 12, 2024 02:58
if now is None:
now = datetime.now(timezone.utc)

if self.state in (State.Learning, State.Review, State.Relearning):
elapsed_days = max(0, (now - self.last_review).days)
return (1 + FACTOR * elapsed_days / self.stability) ** DECAY
Copy link
Member

Choose a reason for hiding this comment

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

Setting self.stability = 0 will trigger an error.

Copy link
Member

Choose a reason for hiding this comment

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

self.stability = 0 only when the state is new, right?

Copy link
Member

Choose a reason for hiding this comment

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

image
Continuously selecting "Again" will cause the stability to approach zero indefinitely.

Copy link
Member

@L-M-Sherlock L-M-Sherlock Sep 12, 2024

Choose a reason for hiding this comment

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

Good point. I haven't known that. @joshdavham, does it happen in py-fsrs?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ishiko732 Yeah, explicitly setting a card's stability to 0 would cause an error if the card is not in the New state. This would probably have to be done by the user though, which I'm not sure they would do. Stability is supposed to be computed internally by the code, not set by user.

Copy link
Member Author

@joshdavham joshdavham Sep 12, 2024

Choose a reason for hiding this comment

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

@L-M-Sherlock You're asking if stability asymptotically approaches 0 when a card's rated again a bunch of times? Yeah it does
Cursor_and_deleteme
I'm not sure if it would every actually reach 0 and cause an error however

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants