How to get pseudo-determinant of a square matrix with python

Viewed 2130

I have a matrix which fails the singular test in which I am calculating for naive bayes classifier. I am handling the ln(det(sigma)) portion of the equation.

if np.linalg.cond(covarianceMatrix) < 1/sys.float_info.epsilon:
    return np.log(np.linalg.det(covarianceMatrix))
else:
    return a pseudo determinant

When the covariance matrix is singular, I must find the pseudo determinant. How can I do that?

2 Answers
Related