ericsuh / dirichlet

Dirichlet MLE python library
MIT License
113 stars 25 forks source link

Using sparse vectors #1

Closed abhijitbendale closed 8 years ago

abhijitbendale commented 9 years ago

Hi Eric,

Thanks a lot for your Dirichlet fitting code. I am using your code on sparse (i.e. lots of zeros) Bag of Words data from images. When I try dirichlet fitting on those, the fitting process blows up and gives lots of NaNs. Sorry, I am little bit new to Dirichlet models, so if question is preliminary, pointing merely to a reference would be good as well. I tried the same features with Tom Minka's matlab toolbox, and it seems to blow up as well.

Thanks again for your code.

Sincerely, Abhijit Bendale PhD Student, University of Colorado

ericsuh commented 8 years ago

I'm not surprised if this blows up on sparse vectors; the psi function (i.e. digamma) is not well defined at 0 when iteratively computed, so this method wouldn't work well and probably wouldn't be stable numerically. Possibly you could make this work using additive smoothing and alter your vectors not to be sparse, but I don't know how well this would work in your particular use case.