Course
machine-learning-zoomcamp
Question
np.linalg.inv(XTX) throws LinAlgError: Singular matrix — what does this mean?
Answer
check np.linalg.matrix_rank(XTX) — if it's less than the number of columns, drop or combine redundant features. Alternatively, use np.linalg.pinv() (pseudo-inverse) instead of inv(), which works even for singular matrices.
Checklist
Course
machine-learning-zoomcamp
Question
np.linalg.inv(XTX) throws LinAlgError: Singular matrix — what does this mean?
Answer
check np.linalg.matrix_rank(XTX) — if it's less than the number of columns, drop or combine redundant features. Alternatively, use np.linalg.pinv() (pseudo-inverse) instead of inv(), which works even for singular matrices.
Checklist