Skip to content

[FAQ] #430

Description

@kunlemariam08

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

  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions