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

Display the number of reviews when pressing “Evaluate” #3123

Closed
dae opened this issue Apr 8, 2024 · 6 comments
Closed

Display the number of reviews when pressing “Evaluate” #3123

dae opened this issue Apr 8, 2024 · 6 comments

Comments

@dae
Copy link
Member

dae commented Apr 8, 2024

The number of reviews is very easy to miss if optimization/evaluation happens too fast, so it would be nice if it was displayed here.

Originally reported on https://forums.ankiweb.net/t/display-the-number-of-reviews-when-pressing-evaluate/43287

@vasll
Copy link
Contributor

vasll commented Apr 12, 2024

In file ts\routes\deck-options\FsrsOptions.svelte
When FSRS is computed the function computeWeights() is called. There the value of computeWeightsProgress is assigned in one of the callbacks. Finally, computeWeightsProgress.reviews is the number of reviews that's shown only briefly on the screen during FSRS optimization.

The idea would be to create a persistent variable where to store the latest FSRS optimization reviews count in Anki. For simplicity I tested this with a variable and initially set it as 0:

let latestOptimizationReviewsCount = 0  // TODO store it persistently

Then in computeWeights() modify the second callback like so:

(progress) => {
    if (progress.value.case === "computeWeights") {
        computeWeightsProgress = progress.value.value;

        // Update latestOptimizationReviewsCount
        if (latestOptimizationReviewsCount == 0 || computeWeightsProgress.reviews != latestOptimizationReviewsCount) {
            latestOptimizationReviewsCount = computeWeightsProgress.reviews
        }
    }
},

To change the dialog in checkWeights() first we need to add a this new .ftl message:

deck-config-latest-optimization-reviews = 
    { $reviewCount ->
        [0] No previous reviews were found.
       *[other] { $reviewCount } reviews in latest FSRS optimization.
    }

And then add it to the alert

alert(
    `Log loss: ${resp.logLoss.toFixed(4)}, RMSE(bins): ${(
        resp.rmseBins * 100
    ).toFixed(2)}%. ${tr.deckConfigSmallerIsBetter()}` +
    ` ${tr.deckConfigLatestOptimizationReviews({reviewCount: latestOptimizationReviewsCount})}`,
),

The result:
Screenshot from 2024-04-12 12-04-44

Edit: I see that Anki uses SQLite and the database is handled via Rust, I'm unsure how to interact with it from Svelte because I'm not familiar with the codebase. By looking at the rslib/src/storage/ dir, I'm guessing I'd have to create a DB insert/update function in Rust and then reach it via an endpoint from Svelte?

To note: From my understanding computeWeightsProgress.reviews is only stored temporarily during the optimization process. If a user has previously done a FSRS optimization (before this new code is added) latestOptimizationReviewsCount will still start at 0, and will only be updated when the user does a new FSRS optimization

@dae
Copy link
Member Author

dae commented Apr 14, 2024

You can see that ComputeFsrsWeightsResponse in the .proto file returns the number of fsrs items. We could do the same with EvaluateWeightsResponse.

@vasll
Copy link
Contributor

vasll commented Apr 14, 2024

I initially didn't look at protobuf, my bad

You mean modifying EvaluateWeightsResponse like this?

message EvaluateWeightsResponse {
  float log_loss = 1;
  float rmse_bins = 2;
  uint32 fsrs_items = 3; <- Add this field
}

Then at weights.rs I'd have to modify evaluate_weights(...) to return the count of fsrs_items, but how can I do this? Are you suggesting that I'd have to implement the same logic of compute_weights(...) for calculating the fsrs_items?

From my understanding the returned fsrs_items in compute_weights(...) is the N reviews from the last FSRS optimization up to the current moment (basically at any point in time, the new FSRS reviews) to be then used for computation, but the intended functionality is to only show the N reviews that were used in the latest FSRS computation/optimization (which is the number of reviews that's only shown briefly while doing the optimization)

@dae
Copy link
Member Author

dae commented Apr 17, 2024

I'm afraid I don't have time at the moment to step you through it - if you're not sure how to proceed, this might not be the best issue to take on.

@abdnh
Copy link
Collaborator

abdnh commented Apr 25, 2024

I assume this was solved by #3165

@dae dae closed this as completed Apr 30, 2024
@Expertium
Copy link
Contributor

Sorry for saying it so late, but I have another suggestion.
When “Evaluate” shows the metrics, make it like this: “Log loss: 0.5000 → 0.4950, RMSE: 4.5% → 4.3%”. That way users won’t have to write down/memorize the numbers.

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

No branches or pull requests

4 participants