open-spaced-repetition/fsrs-rs

[TODO] feature: pre-training for initial stability

Closed this issue · 0 comments

Apply a more efficient method to calculate the initial stability. Then pass the initial stability to the initialization of FSRS model, and freeze the first four parameters.

Python implementation:

https://github.com/open-spaced-repetition/fsrs-optimizer/blob/95694b787bb71ac9883db1201af09e334ee5ee0b/src/fsrs_optimizer/fsrs_optimizer.py#L513-L554

Input:

delta_t = [1, 2, 3, 4, 5]
recall = [0.866842, 0.907582, 0.733485, 0.767769, 0.687690]
count = [435, 97, 63, 38, 28]

Note: this input is generated by:

  S0_dataset = df[df['i'] == 2]
  self.S0_dataset_group = S0_dataset.groupby(by=['r_history', 'delta_t'], group_keys=False).agg({'y': ['mean', 'count']}).reset_index()

We can create it from Vec<FSRSItem>.

Output:

stability = 1.0671915877802147

The output will minimize the loss:

def power_forgetting_curve(t, s):
    return (1 + t / (9 * s)) ** -1

def loss(stability):
    y_pred = power_forgetting_curve(delta_t, stability)
    rmse = np.sqrt(np.sum((recall - y_pred)** 2 * count) / total_count)
    l1 = np.abs(stability - init_s0) / np.sqrt(s0_size) / total_count
    return rmse + l1