Loglikelihood fix#57
Conversation
… input vector X, not just the sum
|
@fkiraly This was the issue (which is a PR) I mentioned in our discussion in skpro! |
|
I see - @tingiskhan, should we merge this? |
I could test if this is still and issue first! |
|
I can confirm that the below script works, so I think we can close this issue now. The problem I had was that I couldn't setup my own optimization problem since the log-likelihood evaluation would fail, but it seems as though that has been remedied. import pykalman as pk
from scipy.optimize import minimize
from scipy.special import expit as sigmoid
import numpy as np
def fun(params, y_):
phi = sigmoid(params[0])
sigma = np.exp(params[1])
f = pk.KalmanFilter(
transition_matrices=phi,
transition_covariance=sigma,
observation_offsets=0.1 ** 2.0
)
return -f.loglikelihood(y_)
f = pk.KalmanFilter(
transition_matrices=0.98,
transition_covariance=0.05 ** 2.0,
observation_covariance=0.1 ** 2.0
)
_, y = f.sample(500)
y[[10, 25, 100], 0] = np.nan
x0 = np.array([0.5, 0.1 ** 2.0])
res = minimize(fun, x0=x0, args=(y,))
print(res)
print(sigmoid(res.x[0]), np.exp(res.x[1] / 2.0)) |
|
should we add a test perhaps? |
Makes sense, I could convert this to a case. |
I now see that there are tests that explicitly call |
|
@tingiskhan, @osh, what do we do about this PR? |
|
We could add the snippet I sent in an earlier post as a test? Could fix this today I think |
|
@tingiskhan, that would be great! |
adding a new accessor for likelihoods on top of davmre's fix -