Skip to main content

Crate fsrs

Crate fsrs 

Source
Expand description

§FSRS-rs

crates.io

The Free Spaced Repetition Scheduler (FSRS) is a modern spaced repetition algorithm. It springs from MaiMemo’s DHP model, which is a variant of the DSR model proposed by Piotr Wozniak.

FSRS-rs is a Rust implementation of FSRS. It also provides simulation capabilities and basic scheduling functionality.

For more information about the algorithm, please refer to the wiki page of FSRS.


Most of the functions in this crate require a struct input. e.g. ComputeParametersInput and FSRSItem.

The most common struct is FSRS which holds the user’s parameters.

§Examples

use chrono::{Duration, Utc};
use fsrs::{FSRS, MemoryState};

let fsrs = FSRS::default();
let desired_retention = 0.9;
let previous_state: Option<MemoryState> = None;
let elapsed_days = 0;

let next_states = fsrs.next_states(previous_state, desired_retention, elapsed_days).unwrap();
let review = next_states.good;

let interval_days = review.interval.round().max(1.0) as u32;
let due = Utc::now() + Duration::days(interval_days as i64);

There are more functions and structures. You can find them here.

Structs§

CMRRTargetFn
A struct holding a function which evaluation the quality.
Card
Holds the full state of a memory card.
CombinedProgressState
Progress for the compute_parameters function.
ComputeParametersInput
Input parameters for computing FSRS parameters.
FSRS
This is the main structure provided by this crate.
FSRSItem
Stores a list of reviews for a card, in chronological order.
FSRSReview
A single review for a card, including the user’s rating and the number of days that passed.
ItemProgress
The learning progress.
ItemState
The state of an item after a review.
MemoryState
Represents the memory state of an item in the FSRS system.
ModelEvaluation
The evaluation metrics of a model.
NextStates
The next states of an item after a review.
PostSchedulingContext
Context for post scheduling operations.
PostSchedulingFn
Function type for post scheduling operations that takes a scheduling context and returns a new interval.
ReviewPriorityFn
Function type for review priority calculation that takes a card reference and returns a priority value (lower value means higher priority)
RevlogEntry
Represents a single review log entry.
SimulationResult
All output data you can get after the simulation ends.
SimulatorConfig
TrainingConfig
Hyperparameters used when training FSRS parameters.

Enums§

FSRSError
Error types and Result alias for the crate. Represents an error that can occur during FSRS operations.
RevlogReviewKind
Represents the review kind of a review log entry.

Constants§

FSRS5_DEFAULT_DECAY
The default decay for FSRS 5.
FSRS6_DEFAULT_DECAY
The default decay for FSRS 6.

Statics§

DEFAULT_PARAMETERS
The default parameters. Fits the average person’s learning habits.

Functions§

benchmark
Assess how good or bad the current parameters are.
check_and_fill_parameters
Checks and fills the parameters with default values if necessary.
compute_parameters
Computes parameters for the FSRS model based on provided training data.
current_retrievability
Calculate the current retrievability for a memory state.
evaluate_with_time_series_splits
Evaluates the model using time series cross-validation.
expected_workload
expected_workload_with_existing_cards
Evaluate expected workload when there are already in-flight cards.
extract_simulator_config
Extracts the simulator configuration from the given review log entries.
filter_outlier
Filters out outlier reviews from two Vec<FSRSItem>.
optimal_retention
For the given simulator parameters and parameters, determine the suggested desired_retention value.
simulate

Type Aliases§

Result
Error types and Result alias for the crate. A type alias for Result with FSRSError as the error type.