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
314 stars 32 forks source link

How to code output #38

Closed elbazjosh closed 4 years ago

elbazjosh commented 4 years ago

Hey All,

I am amazed by the effort and design behind this, and I can only wish for the technical mastery to fully appreciate it. Nonetheless, since the documentation is so good, I wanted to go ahead and experiment with my own project, but I thought it would be instructive to first walk through the how to.

I seem to be having an issue early on. With the following code copied from the Ebisu how to:

import ebisu
from datetime import datetime, timedelta

defaultModel = (4.,4.,24.)

date0 = datetime(2017, 4, 19, 22, 0, 0)

database = [dict(factID=1, model=defaultModel, lastTest=date0),
            dict(factID=2, model=defaultModel, lastTest=date0 + timedelta(hours=11))]

oneHour = timedelta(hours=1)
now = date0 + timedelta(hours=11.1)

print("On {},".format(now))
for row in database:
    recall = ebisu.predictRecall(row['model'], (now - row['lastTest']) / oneHour, exact=True)
    print("Fact #() probability of recall: {:0.1f}%".format(row['factID'], recall * 100))

I get the following output:

On 2017-04-20 09:06:00,
Fact #() probability of recall: 1.0%
Fact #() probability of recall: 2.0%

Process finished with exit code 0

Any ideas on what might be causing the results to print 1% and 2%? Thank you for your time, and I look forward to working through this!

fasiha commented 4 years ago

Welcome, and many thanks for your interest and kind words!

Oops, you have a minor bug in your string replacement fields: if you change "Fact #() probability of recall: {:0.1f}% to "Fact #{} probability of recall: {:0.1f}% (note first pair of parentheses changed to braces), it will work as expected.

Happy to help with further questions!

elbazjosh commented 4 years ago

That's embarrassing thank you!