Comments (6)
I'm glad you like the library and thanks for spotting that something is wrong.
If you can give me a short code example so that I can reproduce the error, it would make my troubleshooting a bit easier. I'll see if I can fix this.
Thanks,
CJ
from piecewise_linear_fit_py.
I think I can replicate the error with the following code
import numpy as np
import pwlf
x = np.array((0.0,1.0,2.0))
y = np.array((0.0,1.0,1.5))
my_fit = pwlf.piecewise_lin_fit(x,y)
x0 = x.copy()
x0[1] = 1.
ssr = my_fit.fitWithBreaks(x0)
Error:
90
91 # calculate the sum of the square of residuals
---> 92 e = self.yData-yHat
93 SSr = np.dot(e.T,e)
94
ValueError: operands could not be broadcast together with shapes (3,) (4,)
If you change x0[1] to something other than 1.0 like 1.001 it works...
Nice find I'll try to fix
from piecewise_linear_fit_py.
Looks like the error I found.
I try to add a piece of code in fitWithBreaks, just before e = self.yData-yHat in order to get rid of the duplicates. It probably could be more synthetic. It seems to work in my situation.
double_ind = []
last_x = [arr[-1] for arr in sepDataX[:-1]]
first_x = [arr[0] for arr in sepDataX[1:]]
indices = []
count = -1
for arr in sepDataX:
count += arr.size
indices.append(count)
for i, (x1, x2) in enumerate(zip(first_x, last_x)):
if x1 == x2:
double_ind.append(indices[i])
yHat = np.delete(yHat, double_ind)
from piecewise_linear_fit_py.
Do the changes in 9d2cd3a fix your issue?
I think you were correct in your original post about aTest, bTest should be a strict greater than or less than.
I'd rather not search for duplicates manually as this may be computationally expensive, but your code should work.
from piecewise_linear_fit_py.
Yes, that seems to correct my issue. I have seen that you also corrected seperateDataX. That's nice, because it was causing trouble to predict in the same situation with breaks on data points.
Thank you very much for your quick answers!
from piecewise_linear_fit_py.
Thanks for pointing this out! If you run into further issues please let me know.
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
- Create a pwlf using custom coefficient HOT 1
- 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.