I'm having having some difficulty implementing a negative log likelihood function in python
My Negative log likelihood function is given as:
This is my implementation but i keep getting error:ValueError: shapes (31,1) and (2458,1) not aligned: 1 (dim 1) != 2458 (dim 0)
def negative_loglikelihood(X, y, theta):
J = np.sum(-y @ X @ theta) + np.sum(np.exp(X @ theta))+ np.sum(np.log(y))
return J
X is a dataframe of size:(2458, 31)
, y is a dataframe of size: (2458, 1)
theta is dataframe of size: (31,1)
i cannot fig out what am i missing. Is my implementation incorrect somehow? Any help would be much appreciated. thanks