Closed SnowdayAurelion closed 4 months ago
In py-fsrs/go-fsrs/ts-fsrs, when determining the card as State.New
, the ratings Rating.Again
, Rating.Hard,
and Rating.Good
are calculated based on the current time(now) plus a certain interval, which is usually less than 1 day.
https://github.com/open-spaced-repetition/py-fsrs/blob/5d36ec32bcac350b489b78dd6c20b26a38582d09/src/fsrs/fsrs.py#L31-L39
Hello, thank you for the share. It 100% seems to be in the right direction, but I'm still facing issues.
I tried to code the due date for the Good and due date for the Hard in the same way the due date for Easy was calculated
if card.state == State.New:
self.init_ds(s)
s.again.due = now + timedelta(minutes=1)
hard_interval = self.next_interval(s.hard.stability) # new lines
s.hard.due = now + timedelta(days=hard_interval)
good_interval = self.next_interval(s.good.stability) # new lines
s.good.due = now + timedelta(days=good_interval)
easy_interval = self.next_interval(s.easy.stability)
s.easy.scheduled_days = easy_interval
s.easy.due = now + timedelta(days=easy_interval)
but it did not work, and then I tried to hard-code it
if card.state == State.New:
self.init_ds(s)
s.again.due = now + timedelta(minutes=1)
# hard_interval = self.next_interval(s.hard.stability) # new lines
s.hard.due = now + timedelta(days=0)
# good_interval = self.next_interval(s.good.stability) # new lines
s.good.due = now + timedelta(days=1)
easy_interval = self.next_interval(s.easy.stability)
s.easy.scheduled_days = easy_interval
s.easy.due = now + timedelta(days=easy_interval)
which fixed the problem for New
cards, but did not fix the problem for new iterations afterwards. I checked my code and it does cycle between the states Learning
and Review
, so the iterations should work.
For example, here is the printed information on iterations that follow that recommend the next due date. So I made the next review date of the study session be the same as the algorithm's recommended due date
Session: 0
State: 0
Card's Difficulty Metric: 0
My Difficulty Metric: 2
Stability: 0
Date studied: 2024-05-19
Due date: 2024-05-20
---
Session: 1
State: 1
Card's Difficulty Metric: 1.0
My Difficulty Metric: 2
Stability: 1.0
Date studied: 2024-05-20
Due date: 2024-05-21
---
Session: 2
State: 2
Card's Difficulty Metric: 1.0
My Difficulty Metric: 2
Stability: 1.0
Date studied: 2024-05-21
Due date: 2024-05-26
---
Session: 3
State: 2
Card's Difficulty Metric: 1.0
My Difficulty Metric: 2
Stability: 4.957026011186596
Date studied: 2024-05-26
Due date: 2024-06-16
---
So Session: 0
is good because it's a 1-day interval for Good (I mean I hard-coded it), but then Session: 1
is wrong because it says a 1-day interval which should be 5. But then all of a sudden the code starts working afterwards??
Session: 2
is the 5-day interval, and then Session: 3
is a 21-day interval. This perfectly follows the algorithm shown on the Anki FSRS Visualizer? So why is the algorithm one session off??
Either way, this is progress, so I'm hyped to hear any more ideas or solutions!
If the ratings are [Rating.Good
, Rating.Good
, Rating.Good
, Rating.Good
], then the due times should be [0, 1, 5, 21] respectively. However, the anki_fsrs_visualizer does not seem to be considering the special handling for the State.New
case correctly, as it is producing a different result of [1, 5, 21, 74](The correct due time should be 75, which is what I get from the results of ts-fsrs
and py-fsrs
).
The difference in 74.08 and 75.04 was due to rounding of the interval in days, and recalculation of retention to 0.89899
The difference in 74.08 and 75.04 was due to rounding of the interval in days, and recalculation of retention to 0.89899
Okay, I've confirmed the data is consistent now.
I've added option to use ts-fsrs lib.
I would switch to ts-fsrs completely, but It handles the first review of cards differently from my implementation of The Algorithm article.
Hello,
I'm trying to use the Anki FSRS Visualizer to fine-tune the perfect algorithm for my Python code that uses Python FSRS, but I'm having a problem. The results that show in the Anki FSRS Visualizer do not match the results from my Python code. I'm particularly looking at the interval data.
Here are my preferences:
request_retention
andmaximum_interval
remain unchanged.For example, when I have difficulty Easy, it works. The interval is 2 days as expected. Note: the difficulty value in my graph does not represent the same difficulty as the values in the fsrs. For me 1 means Easy and 3 means Hard.
But it does not work suddenly for difficulty Good (which creates an interval of 1 day)
I don't think there's an error with my code because the fact that the Easy difficulty worked but not the Good shows that there's an inconsistency elsewhere.
To rule out the error of it being an estimation error, where maybe it could be adding 0.9 days or something, I also tried parameters that made the Good difficulty beyond 1 day and it still did not work.
Last example is when I try two Good sessions in a row, I should get 5 days but I get an interval of 1 day.
If I were to add another Good session it would then be 5 days which is very confusing because now that's the result I want but I had to place an extra study session
By the way, another variable that could be causing this error is how the date studied of my study session does not line up with the recommended due date. But I made sure that the date of the study session does line up.
So I have one Good session, and the algorithm recommends studying in 1 day. So I placed the second Good session one day after, so I expect the algorithm to ask to study again in 5 days. But it doesn't, it says 1 day.
Another problem that I cannot verify is that maybe the algorithm for Anki Visualizer and FSRS Python are not the same. I think that's the most possible problem. Another problem is that maybe making the
initial difficulty (Good)
to the minimum value 1 broke something, but probably not since it works perfectly in the Visualizer.Any ideas or help would be really appreciated. It's frustrating to see the perfect spacing algorithm in front of me but cannot apply it in my code. I really like the FSRS algorithm, and I really want to use it!
By the way, here is my Python code if it needs to be checked. At line 86-91 is where I use a loop to create the card. That has the largest possibility for error, although it seems to been working fine before I tried to fine-tuned the algorithm. So maybe no error there.
Thank you for your time or advice, Aurelion