fasiha / ebisu

Public-domain Python library for flashcard quiz scheduling using Bayesian statistics. (JavaScript, Java, Dart, and other ports available!)
https://fasiha.github.io/ebisu
The Unlicense
303 stars 32 forks source link

Testing with ebisu>=3rc, obtaining a result of probabilityRecall = -1.52. Is this value correct? #65

Open zxl777 opened 5 months ago

zxl777 commented 5 months ago

Output: probabilityRecall = -1.5234768228692503 28.509940322512662 8.099971706104066

Source:

# pip install "ebisu>=3rc"
# pip install attrs

import ebisu

# create an Ebisu model when the student has learned this flashcard
model = ebisu.initModel(
    firstHalflife=10, lastHalflife=10e3, firstWeight=0.9, numAtoms=5, initialAlphaBeta=2.0)

# at some point later, ask Ebisu for this flashcard's recall probability
timeSinceLastReview = 20
probabilityRecall = ebisu.predictRecall(model, timeSinceLastReview)
print("probabilityRecall =", probabilityRecall)

# administer a quiz, then update the model, overwriting the old one
timeSinceLastReview = 20.1
model = ebisu.updateRecall(model, successes=1, total=1,
                           elapsedTime=timeSinceLastReview)

# that's a binary quiz. You can also do a binomial quiz:
model = ebisu.updateRecall(model, successes=1, total=2,
                           elapsedTime=timeSinceLastReview)

# you can also do fuzzy-binary quizzes, see Ebisu v2 docs
model = ebisu.updateRecall(model, successes=0.85,
                           total=1, elapsedTime=timeSinceLastReview, q0=0.1)

# how long do we expect it to take for recall to drop to 50%?
print(ebisu.modelToPercentileDecay(model, 0.5))

# how long till recall drops to 80%?
print(ebisu.modelToPercentileDecay(model, 0.8))

# sometimes the model is just too hard or too easy. There's an ad hoc backdoor to rescaling it:
# new halflife = 0.25 * old halflife
easierModel = ebisu.rescaleHalflife(model, 0.25)
# new halflife = 4 * old halflife
harderModel = ebisu.rescaleHalflife(model, 4)
fasiha commented 5 months ago

Yah this is fine, predictRecall is returning log-probability. For real probability, pass in logDomain=False:

print([
  ebisu.predictRecall(model, timeSinceLastReview), # what you have
  ebisu.predictRecall(model, timeSinceLastReview, logDomain=False), # ask for linear domain
  2**ebisu.predictRecall(model, timeSinceLastReview) # do the exponential yourself
])
# -1.5234768228692503 0.34784661272006395 0.34784661272006395
zxl777 commented 5 months ago

Thank you.

Looking forward to the new IPython Notebook crash course for 3.0.