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

[Feature Request] script for local optimization #361

Closed
ruilya opened this issue Jul 18, 2023 · 4 comments
Closed

[Feature Request] script for local optimization #361

ruilya opened this issue Jul 18, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@ruilya
Copy link

ruilya commented Jul 18, 2023

Which module is related to your feature request?
Optimizer

Is your feature request related to a problem? Please describe.
I don't like the idea of uploading my anki cards to collab and doing things with it there. Instead there could be a way to run the optimizer locally and with this feature one could automate the process of optimizing without visiting google infrastructure and uploading decks by hand.

Describe the solution you'd like
A simple python script could be provided in the repo, something like the following but with parameters held as commandline arguments (e.g. deck filename, timezone, etc):

#!/usr/bin/python3

# Here are some settings that you need to replace before running this optimizer.

filename = "all.apkg"
# If you upload deck file, replace it with your deck filename. E.g., ALL__Learning.apkg
# If you upload collection file, replace it with your colpgk filename. E.g., collection-2022-09-18@13-21-58.colpkg

# Replace it with your timezone. I'm in China, so I use Asia/Shanghai.
# You can find your timezone here: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568
timezone = 'Europe/London'

# Replace it with your Anki's setting in Preferences -> Scheduling.
next_day_starts_at = 4

# Replace it if you don't want the optimizer to use the review logs before a specific date.
revlog_start_date = "2006-10-05"

import os
import sys
sys.path.insert(0, os.path.abspath('./package/fsrs4anki_optimizer'))
import fsrs4anki_optimizer as optimizer
optimizer = optimizer.Optimizer()
optimizer.anki_extract(filename)

analysis = optimizer.create_time_series(timezone, revlog_start_date, next_day_starts_at)
print(analysis)

"""
w[0]: initial_stability_for_again_answer
w[1]: initial_stability_step_per_rating
w[2]: initial_difficulty_for_good_answer
w[3]: initial_difficulty_step_per_rating
w[4]: next_difficulty_step_per_rating
w[5]: next_difficulty_reversion_to_mean_speed (used to avoid ease hell)
w[6]: next_stability_factor_after_success
w[7]: next_stability_stabilization_decay_after_success
w[8]: next_stability_retrievability_gain_after_success
w[9]: next_stability_factor_after_failure
w[10]: next_stability_difficulty_decay_after_success
w[11]: next_stability_stability_gain_after_failure
w[12]: next_stability_retrievability_gain_after_failure
For more details about the parameters, please see: 
https://github.com/open-spaced-repetition/fsrs4anki/wiki/Free-Spaced-Repetition-Scheduler
"""
optimizer.define_model()
print(optimizer.init_w)

optimizer.train()

print(optimizer.w)

Describe alternatives you've considered
One could have written it on his own, but this involves synchronizing the script with the main codebase in case it changes.

Additional context
Add any other context or screenshots about the feature request here.

@ruilya ruilya added the enhancement New feature or request label Jul 18, 2023
@L-M-Sherlock
Copy link
Member

@L-M-Sherlock
Copy link
Member

You can run the script with interactive mode in dir package:

python -i fsrs4anki_optimizer ../collection-2022-09-18@13-21-58.colpkg

image

@ruilya
Copy link
Author

ruilya commented Jul 19, 2023

You can run the script with interactive mode in dir package:

python -i fsrs4anki_optimizer ../collection-2022-09-18@13-21-58.colpkg

That was exactly what I was looking for. Can this be documented?

@L-M-Sherlock
Copy link
Member

It is not implemented by myself. You can ask @Luc-Mcgrady.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants