Comments (11)
You can now manually specify rcond when you initialize pwlf. bf67d7d
I will push pwlf==0.4.3 to pypi shortly.
my_pwlf = pwlf.PiecewiseLinFit(x, y, rcond=-1)
The default is still rcond=None
.
from piecewise_linear_fit_py.
Can you give me the versions of numpy and pwlf?
pwlf.__version__
np.__version__
from piecewise_linear_fit_py.
pwlf.version 0.3.3
np.version 1.14.3
from piecewise_linear_fit_py.
I'll have to create an environment with numpy==1.14.3 later today. I know numpy<1.14 would break because they changed how rcond
is handled.
In the meantime is it possible for you to update numpy to at least numpy>=1.15.4 and see if that fixes your problem?
I think the anaconda command within your environment would be
conda update numpy
Can you run this simple least squares fit? Or do you get the same error?
# https://stackoverflow.com/questions/27128688/how-to-use-least-squares-with-weight-matrix-in-python
import numpy as np
A=np.array([[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,0,0]])
B = np.array([1,1,1,1,1])
W = np.array([1,2,3,4,5])
Aw = A * np.sqrt(W[:,np.newaxis])
Bw = B * np.sqrt(W)
X = np.linalg.lstsq(Aw, Bw, rcond=None)
from piecewise_linear_fit_py.
Thank you! By upgrading my numpy to 1.15.4, the problem disappears! 👍
from piecewise_linear_fit_py.
I'm glad you got it working!
I tried setting up a numpy==0.14.3 environment and couldn't reproduce. I think something was wrong with your numpy build =/
Edit. I should note that I was expecting this error to occur from numpy<=0.14. Perhaps I should I add rcond as an optional parameter in the class...
from piecewise_linear_fit_py.
FYI, I keep seeing the same error with the pwlf==0.4.2
and numpy==1.16.2
.
Running the code from above produces
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-e4acef74a3ed> in <module>()
5 Aw = A * np.sqrt(W[:,np.newaxis])
6 Bw = B * np.sqrt(W)
----> 7 X = np.linalg.lstsq(Aw, Bw, rcond=None)
/opt/conda/lib/python3.6/site-packages/numpy/linalg/linalg.py in lstsq(a, b, rcond)
1913 work = zeros((lwork,), t)
1914 results = lapack_routine(m, n, n_rhs, a, m, bstar, ldb, s, rcond,
-> 1915 0, work, -1, iwork, 0)
1916 lwork = int(work[0])
1917 work = zeros((lwork,), t)
TypeError: must be real number, not NoneType
changing rcond=-1
a suggested here makes it work again.
from piecewise_linear_fit_py.
@stklik Are you absolute sure that you are running numpy==1.16.2
? If so, you should raise an issue on numpy that recommended default of rcond=None
does not work with all numpy backends.
Some old discussion on the topic:
numpy/numpy#11015
numpy/numpy#9582
In terms of pwlf, I could make a parameter in __init__
which sets and option for rcond, allowing for backwards compatibility.
from piecewise_linear_fit_py.
so, my pip freeze | grep numpy
tells me it's 1.16.2
.
I'm running inside a Docker image, so I'll try to check if there are any issues with the installations.
I will push pwlf==0.4.3 to pypi shortly.
Thanks, this will certainly solve my problem.
from piecewise_linear_fit_py.
@cjekel After further investigation, I am fairly convinced that my issue has to do with the Jupyter dockerstacks and the fact that they use conda to install numpy while pwlf setup triggers a pip install + some access rights issues.
I will investigate and raise it with the people over there if I find out what to do.
PS: Thanks for adding the rcond
param, it works for me now, despite "my situation".
--> can be closed from my POV
from piecewise_linear_fit_py.
Having multiple Python instances is a pain. The pip in your docker setup is probably for the OS's python. I normally run
which pip
which pip3
which pip3.6
to give some idea where the pip files are located. It's possible that one of those is your conda pip. You may have more options... Feel free to email me if you can't seem to get it sorted out.
You can also try
python -m pip install pwlf
to make sure that this Python environment is the same as pip.
If anything rcond
adds backwards compatibility for someone stuck on numpy <= 1.14. :)
from piecewise_linear_fit_py.
Related Issues (20)
- .fit() fails with 1 segment HOT 5
- How to force the fit process to have a fixed Intercept? HOT 1
- Can I get y_values if I have only x and slopes values? HOT 1
- Limit the slope of each segment of the curve HOT 1
- Re-constructing Piecewise PWLF HOT 2
- Set Slope of Segment to 0 HOT 2
- How to fit multiple functions simultaneously HOT 3
- Hi, i want to make sure that there are no fitted lines between points that are too far apart i.e. set a min value( fragment optimization) how to achieve this? HOT 1
- Why last beta is always positive? HOT 3
- How to prevent poor fitting HOT 4
- Forcing the segments to be integers and not float
- p values does not seem accurate HOT 3
- Error for coefficients of linear equations HOT 7
- pwlf with unknown line segments HOT 9
- assure the slopes to be lower and lower HOT 1
- divide by zero error in calc slopes if two break points are the same, or if a breakpoint is on the boundary HOT 2
- Issue using .fit() HOT 5
- How to plot segments with fit_breaks information HOT 4
- support random seed on init
- How to calculate prediction intervals? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piecewise_linear_fit_py.