Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

numpy.linalg.LinAlgError: Matrix is singular to machine precision

$
0
0

I'm trying to use bai-perron code from https://github.com/ceholden/pybreakpoints repo.

My python version is 3.12.2

The code I wrote is similar to their test.

    from pybreakpoints.baiperron import breakpoint    import numpy as np    import pandas as pd    nile = pd.read_csv("tests/data/nile.csv")    X = np.ones_like(nile)    results = breakpoint(X, nile)

But I got errors.

mytest.py", line 9, in <module>    results = breakpoint(X, nile)              ^^^^^^^^^^^^^^^^^^^\pybreakpoints\baiperron.py", line 76, in breakpoint    ssr = recresid(X_[i:n, :], y_[i:n])          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\pybreakpoints\recresid_.py", line 134, in recresid    rresid = _recresid(_X, _y, span)[span:]             ^^^^^^^^^^^^^^^^^^^^^^^\Python312\Lib\site-packages\numba\np\linalg.py", line 899, in _inv_err_handler    raise np.linalg.LinAlgError(numpy.linalg.LinAlgError: Matrix is singular to machine precision.

Since it is the data from the repo the test should at least be able to run. I suspect this is just data format problem but I'm new to python and not sure how to debug.


Viewing all articles
Browse latest Browse all 23160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>