Skip to content

Commit

Permalink
Feat/preview intervals with different ratings (#29)
Browse files Browse the repository at this point in the history
* add preview different first rating

* add preview different rating sequences
  • Loading branch information
L-M-Sherlock committed Sep 26, 2022
1 parent c3f33b2 commit d0b9b17
Showing 1 changed file with 107 additions and 41 deletions.
148 changes: 107 additions & 41 deletions fsrs4anki_optimizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# FSRS4Anki v1.4.3 Optimizer"
"# FSRS4Anki v1.6.0 Optimizer"
]
},
{
Expand All @@ -13,8 +13,10 @@
"id": "lurCmW0Jqz3s"
},
"source": [
"[![](https://colab.research.google.com/assets/colab-badge.svg)\n",
"](https://colab.research.google.com/github/open-spaced-repetition/fsrs4anki/blob/v1.4.3/fsrs4anki_optimizer.ipynb)"
"Click the left button to open the optimizer on Google Colab: [![open in colab](https://colab.research.google.com/assets/colab-badge.svg)\n",
"](https://colab.research.google.com/github/open-spaced-repetition/fsrs4anki/blob/v1.6.0/fsrs4anki_optimizer.ipynb)\n",
"\n",
"> If you can't see the button and are located in the Chinese Mainland, please use a proxy or VPN."
]
},
{
Expand All @@ -23,7 +25,9 @@
"id": "wG7bBfGJFbMr"
},
"source": [
"Upload your **Anki Deck Package (.apkg)** file or **Anki Collection Package (.colpkg)** file. No need to include media. Need to include scheduling information. \n",
"Upload your **Anki Deck Package (.apkg)** file or **Anki Collection Package (.colpkg)** file on the `Left sidebar -> Files`, drag and drop your file in the current directory (not the `sample_data` directory). \n",
"\n",
"No need to include media. Need to include scheduling information. \n",
"\n",
"> If you use the latest version of Anki, please check the box `Support older Anki versions (slower/larger files)` when you export.\n",
"\n",
Expand Down Expand Up @@ -157,7 +161,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 5166/5166 [00:20<00:00, 255.39it/s]\n"
"100%|██████████| 5166/5166 [00:16<00:00, 317.48it/s]\n"
]
},
{
Expand Down Expand Up @@ -406,7 +410,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 56910/56910 [00:04<00:00, 13168.59it/s]\n"
"100%|██████████| 56910/56910 [00:03<00:00, 15572.48it/s]\n"
]
},
{
Expand All @@ -420,7 +424,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 0%|\u001b[31m \u001b[0m| 23/56910 [00:00<04:12, 225.37it/s]"
"train: 0%|\u001b[31m \u001b[0m| 28/56910 [00:00<03:25, 277.11it/s]"
]
},
{
Expand All @@ -437,7 +441,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 10%|\u001b[31m█ \u001b[0m| 5770/56910 [00:16<02:07, 402.49it/s]"
"train: 10%|\u001b[31m█ \u001b[0m| 5741/56910 [00:13<01:58, 432.54it/s]"
]
},
{
Expand All @@ -454,7 +458,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 20%|\u001b[31m██ \u001b[0m| 11439/56910 [00:30<01:52, 405.82it/s]"
"train: 20%|\u001b[31m██ \u001b[0m| 11447/56910 [00:26<01:49, 416.76it/s]"
]
},
{
Expand All @@ -471,7 +475,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 30%|\u001b[31m███ \u001b[0m| 17151/56910 [00:47<01:39, 400.30it/s]"
"train: 30%|\u001b[31m███ \u001b[0m| 17140/56910 [00:41<01:32, 430.78it/s]"
]
},
{
Expand All @@ -488,7 +492,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 40%|\u001b[31m████ \u001b[0m| 22794/56910 [01:03<02:12, 256.89it/s]"
"train: 40%|\u001b[31m████ \u001b[0m| 22819/56910 [00:57<01:49, 312.71it/s]"
]
},
{
Expand All @@ -505,7 +509,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 50%|\u001b[31m█████ \u001b[0m| 28467/56910 [01:19<01:21, 350.42it/s]"
"train: 50%|\u001b[31m█████ \u001b[0m| 28501/56910 [01:13<01:14, 382.50it/s]"
]
},
{
Expand All @@ -522,7 +526,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 60%|\u001b[31m██████ \u001b[0m| 34232/56910 [01:34<00:51, 438.17it/s]"
"train: 60%|\u001b[31m██████ \u001b[0m| 34235/56910 [01:27<00:51, 437.34it/s]"
]
},
{
Expand All @@ -539,7 +543,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 70%|\u001b[31m███████ \u001b[0m| 39865/56910 [01:48<00:44, 380.06it/s]"
"train: 70%|\u001b[31m███████ \u001b[0m| 39905/56910 [01:42<00:43, 394.01it/s]"
]
},
{
Expand All @@ -556,7 +560,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 80%|\u001b[31m████████ \u001b[0m| 45562/56910 [02:03<00:33, 342.14it/s]"
"train: 80%|\u001b[31m████████ \u001b[0m| 45564/56910 [01:57<00:29, 380.48it/s]"
]
},
{
Expand All @@ -573,7 +577,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 90%|\u001b[31m█████████ \u001b[0m| 51264/56910 [02:18<00:14, 391.97it/s]"
"train: 90%|\u001b[31m█████████ \u001b[0m| 51229/56910 [02:12<00:19, 284.91it/s]"
]
},
{
Expand All @@ -590,7 +594,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"train: 100%|\u001b[31m██████████\u001b[0m| 56910/56910 [02:34<00:00, 368.73it/s]"
"train: 100%|\u001b[31m██████████\u001b[0m| 56910/56910 [02:27<00:00, 385.32it/s]"
]
},
{
Expand Down Expand Up @@ -742,23 +746,28 @@
"name": "stdout",
"output_type": "stream",
"text": [
"stability, difficulty, lapses\n",
" 2.56 4.62 0\n",
" 5.85 4.60 0\n",
" 11.72 4.60 0\n",
" 22.38 4.60 0\n",
" 40.26 4.60 0\n",
" 70.23 4.60 0\n",
" 118.80 4.60 0\n",
" 195.57 4.60 0\n",
" 313.61 4.60 0\n",
" 490.77 4.60 0\n",
" 751.17 4.60 0\n",
" 1126.71 4.60 0\n",
" 1659.56 4.60 0\n",
" 2403.52 4.60 0\n",
" 3427.16 4.60 0\n",
"0,3,6,12,22,40,70,119,196,314,491,751,1127,1660,2404,3427\n"
"1:again, 2:hard, 3:good, 4:easy\n",
"\n",
"first rating: 1\n",
"rating history: 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3\n",
"interval history: 0,1,2,4,7,12,21,35,57,90,139,211,313,457,657,929\n",
"difficulty history: 0,6.6,6.6,6.6,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5\n",
"\n",
"first rating: 2\n",
"rating history: 2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3\n",
"interval history: 0,1,2,4,8,15,26,44,73,118,185,285,429,635,923,1321\n",
"difficulty history: 0,5.6,5.6,5.7,5.7,5.7,5.7,5.7,5.7,5.7,5.7,5.7,5.7,5.7,5.7,5.7\n",
"\n",
"first rating: 3\n",
"rating history: 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3\n",
"interval history: 0,3,6,12,22,40,70,119,196,314,491,751,1127,1660,2404,3427\n",
"difficulty history: 0,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6,4.6\n",
"\n",
"first rating: 4\n",
"rating history: 4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3\n",
"interval history: 0,5,11,22,43,79,141,243,406,660,1046,1620,2456,3653,5339,7676\n",
"difficulty history: 0,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6,3.6\n",
"\n"
]
}
],
Expand All @@ -780,17 +789,74 @@
"\n",
"\n",
"my_collection = Collection()\n",
"print(\"1:again, 2:hard, 3:good, 4:easy\\n\")\n",
"for first_rating in (1,2,3,4):\n",
" print(f'first rating: {first_rating}')\n",
" t_history = \"0\"\n",
" d_history = \"0\"\n",
" r_history = f\"{first_rating}\" # the first rating of the new card\n",
" # print(\"stability, difficulty, lapses\")\n",
" for i in range(15):\n",
" states = my_collection.states(t_history, r_history)\n",
" # print('{0:9.2f} {1:11.2f} {2:7.0f}'.format(\n",
" # *list(map(lambda x: round(float(x), 4), states))))\n",
" next_t = round(float(np.log(requestRetention)/np.log(0.9) * states[0]))\n",
" difficulty = round(float(np.log(requestRetention)/np.log(0.9) * states[1]), 1)\n",
" t_history += f',{int(next_t)}'\n",
" d_history += f',{difficulty}'\n",
" r_history += f\",3\"\n",
" print(f\"rating history: {r_history}\")\n",
" print(f\"interval history: {t_history}\")\n",
" print(f\"difficulty history: {d_history}\")\n",
" print('')\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can change the `test_rating_sequence` to see the scheduling intervals in different ratings."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rating history: 3,3,3,2,3,4,3,3,1,3,3,3\n",
"interval history: 0,3,6,12,14,33,74,113,192,3,6,11,21\n",
"difficulty history: 0,4.6,4.6,4.6,5.1,5.1,4.1,4.1,4.1,4.9,4.8,4.8,4.8\n"
]
}
],
"source": [
"test_rating_sequence = \"3,3,3,2,3,4,3,3,1,3,3,3\"\n",
"requestRetention = 0.9 # recommended setting: 0.8 ~ 0.9\n",
"easyBonus = 1.3\n",
"hardInterval = 1.2\n",
"\n",
"t_history = \"0\"\n",
"r_history = \"3\" # the first rating of the new card\n",
"print(\"stability, difficulty, lapses\")\n",
"for i in range(15):\n",
"d_history = \"0\"\n",
"for i in range(len(test_rating_sequence.split(','))):\n",
" rating = test_rating_sequence[2*i]\n",
" last_t = int(t_history.split(',')[-1])\n",
" r_history = test_rating_sequence[:2*i+1]\n",
" states = my_collection.states(t_history, r_history)\n",
" print('{0:9.2f} {1:11.2f} {2:7.0f}'.format(\n",
" *list(map(lambda x: round(float(x), 4), states))))\n",
" next_t = round(float(np.log(requestRetention)/np.log(0.9) * states[0]))\n",
" if rating == '4':\n",
" next_t = round(next_t * easyBonus)\n",
" elif rating == '2':\n",
" next_t = round(last_t * hardInterval)\n",
" t_history += f',{int(next_t)}'\n",
" r_history += f\",3\"\n",
"print(t_history)\n"
" difficulty = round(float(np.log(requestRetention)/np.log(0.9) * states[1]), 1)\n",
" d_history += f',{difficulty}'\n",
"print(f\"rating history: {test_rating_sequence}\")\n",
"print(f\"interval history: {t_history}\")\n",
"print(f\"difficulty history: {d_history}\")"
]
}
],
Expand Down

0 comments on commit d0b9b17

Please sign in to comment.