fsrs

Struct FSRS

Source
pub struct FSRS<B: Backend = NdArray> { /* private fields */ }
Expand description

This is the main structure provided by this crate. It can be used for both parameter training, and for reviews.

Implementations§

Source§

impl<B: Backend> FSRS<B>

Source

pub fn memory_state( &self, item: FSRSItem, starting_state: Option<MemoryState>, ) -> Result<MemoryState>

Calculate the current memory state for a given card’s history of reviews. In the case of truncated reviews, starting_state can be set to the value of FSRS::memory_state_from_sm2 for the first review (which should not be included in FSRSItem). If not provided, the card starts as new. Parameters must have been provided when calling FSRS::new().

Source

pub fn memory_state_from_sm2( &self, ease_factor: f32, interval: f32, sm2_retention: f32, ) -> Result<MemoryState>

If a card has incomplete learning history, memory state can be approximated from current sm2 values. Parameters must have been provided when calling FSRS::new().

Source

pub fn next_interval( &self, stability: Option<f32>, desired_retention: f32, rating: u32, ) -> f32

Calculate the next interval for the current memory state, for rescheduling. Stability should be provided except when the card is new. Rating is ignored except when card is new. Parameters must have been provided when calling FSRS::new().

Source

pub fn next_states( &self, current_memory_state: Option<MemoryState>, desired_retention: f32, days_elapsed: u32, ) -> Result<NextStates>

The intervals and memory states for each answer button. Parameters must have been provided when calling FSRS::new().

Source

pub fn evaluate<F>( &self, items: Vec<FSRSItem>, progress: F, ) -> Result<ModelEvaluation>
where F: FnMut(ItemProgress) -> bool,

Determine how well the model and parameters predict performance. Parameters must have been provided when calling FSRS::new().

Source

pub fn current_retrievability( &self, state: MemoryState, days_elapsed: u32, ) -> f32

How well the user is likely to remember the item after days_elapsed since the previous review.

Source

pub fn universal_metrics<F>( &self, items: Vec<FSRSItem>, parameters: &[f32], progress: F, ) -> Result<(f32, f32)>
where F: FnMut(ItemProgress) -> bool,

Returns the universal metrics for the existing and provided parameters. If the first value is smaller than the second value, the existing parameters are better than the provided ones.

Source§

impl FSRS<NdArray>

Source

pub fn new(parameters: Option<&[f32]>) -> Result<Self>

  • Parameters must be provided before running commands that need them.
  • Parameters may be an empty slice to use the default values instead.
Source§

impl<B: Backend> FSRS<B>

Source

pub fn new_with_backend<B2: Backend>( parameters: Option<&[f32]>, device: B2::Device, ) -> Result<FSRS<B2>>

Source§

impl<B: Backend> FSRS<B>

Source

pub fn optimal_retention<F>( &self, config: &SimulatorConfig, parameters: &[f32], progress: F, ) -> Result<f32>
where F: FnMut(ItemProgress) -> bool + Send,

For the given simulator parameters and parameters, determine the suggested desired_retention value.

Source§

impl<B: Backend> FSRS<B>

Source

pub fn compute_parameters( &self, train_set: Vec<FSRSItem>, progress: Option<Arc<Mutex<CombinedProgressState>>>, enable_short_term: bool, ) -> Result<Vec<f32>>

Calculate appropriate parameters for the provided review history.

Source

pub fn benchmark( &self, train_set: Vec<FSRSItem>, enable_short_term: bool, ) -> Vec<f32>

Trait Implementations§

Source§

impl<B: Clone + Backend> Clone for FSRS<B>
where B::Device: Clone,

Source§

fn clone(&self) -> FSRS<B>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Debug + Backend> Debug for FSRS<B>
where B::Device: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B = NdArray> !Freeze for FSRS<B>

§

impl<B = NdArray> !RefUnwindSafe for FSRS<B>

§

impl<B> Send for FSRS<B>

§

impl<B = NdArray> !Sync for FSRS<B>

§

impl<B> Unpin for FSRS<B>
where <B as Backend>::Device: Unpin, <B as Backend>::FloatTensorPrimitive<1>: Unpin,

§

impl<B> UnwindSafe for FSRS<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V