SpringRank icon indicating copy to clipboard operation
SpringRank copied to clipboard

Which beta is being calculated by get_optimal_temperature on tools.py?

Open edsf70 opened this issue 6 years ago • 5 comments

On tools.py which beta is calculated by get_optimal_temperature? Global or local beta? Would you please be so kind providing functions to calculate both? Thank you very much indeed!

edsf70 avatar Dec 17 '18 12:12 edsf70

This is the beta maximizing the conditional loglikelihood, i.e. the global one. It uses a root-finding method (brentq), to solve eq S39 of the paper (in the Supplementary Material). I will upload in the next few days a similar equivalent to calculate the local one, i.e. an implementation for eq. S36.

I will also upload an alternative method: instead of solving via root-finding method, one can use scipy.optimize.fmin_l_bfgs_b() to make python search for the optimal parameter value in order to maximize a function. This method allows to define custom cost functions, scipy.optimize does the rest.

cdebacco avatar Dec 18 '18 08:12 cdebacco

This is the beta maximizing the conditional loglikelihood, i.e. the global one. It uses a root-finding method (brentq), to solve eq S39 of the paper (in the Supplementary Material). I will upload in the next few days a similar equivalent to calculate the local one, i.e. an implementation for eq. S36.

I will also upload an alternative method: instead of solving via root-finding method, one can use scipy.optimize.fmin_l_bfgs_b() to make python search for the optimal parameter value in order to maximize a function. This method allows to define custom cost functions, scipy.optimize does the rest.

Il giorno lun 17 dic 2018 alle ore 13:04 edsf70 [email protected] ha scritto:

On tools.py which beta is calculated by get_optimal_temperature? Global or local beta? Would you please be so kind providing functions to calculate both? Thank you very much indeed!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cdebacco/SpringRank/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/ARSx93_I3sx9u52wwdXd33Ad3o_DHy7gks5u54hagaJpZM4ZWOOf .

cdebacco avatar Dec 18 '18 08:12 cdebacco

This is the beta maximizing the conditional loglikelihood, i.e. the global one. It uses a root-finding method (brentq), to solve eq S39 of the paper (in the Supplementary Material). I will upload in the next few days a similar equivalent to calculate the local one, i.e. an implementation for eq. S36. I will also upload an alternative method: instead of solving via root-finding method, one can use scipy.optimize.fmin_l_bfgs_b() to make python search for the optimal parameter value in order to maximize a function. This method allows to define custom cost functions, scipy.optimize does the rest. Il giorno lun 17 dic 2018 alle ore 13:04 edsf70 [email protected] ha scritto: On tools.py which beta is calculated by get_optimal_temperature? Global or local beta? Would you please be so kind providing functions to calculate both? Thank you very much indeed! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#8>, or mute the thread https://github.com/notifications/unsubscribe-auth/ARSx93_I3sx9u52wwdXd33Ad3o_DHy7gks5u54hagaJpZM4ZWOOf .

That would be great!!! Thank you very much indeed!!

edsf70 avatar Dec 20 '18 13:12 edsf70

Would you please be so kind telling me if there is already an implementation for eq. S36 (local Beta)?

edsf70 avatar Jul 15 '19 04:07 edsf70

@edsf70 I've implemented it based on the eqs39 implementation and it turned out like this:

def eqs36(beta, s, A):
    N = A.shape[0]
    x = 0
    for i in range(N):
        for j in range(N):
            if A[i, j] == 0:
                continue
            else:
                pij =  1 / (1 + np.exp(-2 * beta * (s[i] - s[j])))
                signed = np.sign(A[i, j] - (A[i, j] + A[j, i])*pij)
                x += signed * ((A[i, j] - A[j, i])*(s[i] - s[j])) / ( np.cosh(2*beta*(s[i] - s[j])) + 1)
    return x

Only thing is that it is not nopython=True as eqs39, but it didn't seem an issue.

nicholasdomene avatar Nov 24 '21 03:11 nicholasdomene