I'm surprised to not even find a Java library that...
# mathematics
b
I'm surprised to not even find a Java library that can do that (automatic differentiation and all of that)
a
We actually have 3 different kotlin ways of automatic differentiation: • kotlingrad (https://github.com/breandan/kotlingrad). It has the best documentation ever and the integration with kmath is ongoing (https://github.com/mipt-npm/kmath/issues/149)
• An automatic differentiation with forward variable declaration via Commons Math DerivativeStructure (https://github.com/mipt-npm/kmath/blob/master/kmath-commons/src/test/kotlin/scientifik/kmath/commons/expressions/AutoDiffTest.kt). It is a Java library. • A @elizarov kotlin-common algorithm for first order differentiation: https://github.com/mipt-npm/kmath/blob/master/kmath-core/src/commonTest/kotlin/scientifik/kmath/misc/AutoDiffTest.kt
The documentation is not the best at the moment and we need to somehow produce a generic API for all those features, but you can use it in currently released versions. Don't forget to vote issued and leave comments so we could prioritize and update the documentation and features according to your requests. Currently, with the help of @Peter Klimai and @Iaroslav Postovalov the release cycle for requested features could be really short.
b
Really nice! I'll check that
a
The integration with kotlingrad seems to be the most interesting direction. It would allow to combine the power of symbolic differentiation with numerous kmath integrations.
b
I'm trying kotlingrad right now, but even the simplest program get stuck when a loss function is called (it opens a graph in my web browser and then hangs there)
it doesn't even do an epoch, I'm trying the sample LinearRegression.kt from kotlingrad
Even taking from his git repo, the samples don't run (tried LinearRegression, MLP, Polynomial regression)
They all fail with a "kotlin.NotImplementedError: An operation is not implemented"
a
Сс @breandan
By the way, @bjonnh Could you explain your problem a little bit. If it is a simple 2d fit, I can show you how to do it with commons math (included in kmath-commons).
b
I want to fit y~ a+ b / (1+(x/d)^n )
Optimizing for a,b,d,n given series of y_n and x_n
But really if I could have something like scipy where I just have to write my equation and it fits almost automatically that would be nice as it is a problem I regularly have
Even without that I would be happy to know how to do it even if I have to do the derivations by hand.
a
Scipy does derivations numerically as well as CM fitters. Here is the article about it: https://commons.apache.org/proper/commons-math/userguide/optimization.html. What you need right now is the direct Nelder-Mead fitter since you do not want to provide derivatives and you do not care about the performance. I have a long-standing plan to add more concise API to kmath, but sadly, I am completely overwhelmed right now with money-finding and money-spending activities (blast it all!). I am really getting tired of all that.
not found 😄
a
indeed...
I am currently finalizing autodiff API. I think it would be simple to befriend it with commons-math.
b
@bjonnh 0.3.7 should fix this issue. The linear/polynomial/MLP regression samples seem to be working again, although very slowly, so YMMV. Thanks for the heads up
b
Thanks for the reactivity! that's deeply appreciated