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

[WIP] fit2: fast version of fitting algorithm #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajinkya-k
Copy link

@ajinkya-k ajinkya-k commented Mar 27, 2025

would complete #13 when done

started working on a faster version of the fitting algorithm in this draft PR. Suggestions would be helpful!

I am thinking of experimenting with the utbl/ytbl stuff that @dmbates wrote about in the Embrace Uncertainty book.

link to the branch on my fork for easy access: https://github.com/ajinkya-k/BetaRegression.jl/tree/ahk/fast-fit

TODOs:

  • compare performance on a battery of tests
  • pre-allocate all intermediate quantities like utbl/ytbl in EmbraceUncertainty

@ajinkya-k
Copy link
Author

As I mentioned in #13, this leads to a decent speedup as is. I think the speed up will improve once I allocate only once all vectors for intermediate quantities (like digamma and trigamma and mu_i) that are used in both the score and the information matrix using @dmbates 's utbl idea

julia> @be fit!(bm)
Benchmark: 2517 samples with 1 evaluation
 min    31.459 μs (242 allocs: 31.844 KiB)
 median 33.042 μs (242 allocs: 31.844 KiB)
 mean   37.471 μs (242 allocs: 31.844 KiB, 0.19% gc time)
 max    2.274 ms (242 allocs: 31.844 KiB, 97.26% gc time)

julia> @be BetaRegression.fit2!(bm)
Benchmark: 3146 samples with 1 evaluation
 min    26.958 μs (172 allocs: 27.406 KiB)
 median 27.584 μs (172 allocs: 27.406 KiB)
 mean   28.967 μs (172 allocs: 27.406 KiB, 0.15% gc time)
 max    1.844 ms (172 allocs: 27.406 KiB, 97.55% gc time)

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

Successfully merging this pull request may close these issues.

1 participant