Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I get y_values if I have only x and slopes values? #104

Open
esakhib opened this issue Aug 2, 2022 · 1 comment
Open

Can I get y_values if I have only x and slopes values? #104

esakhib opened this issue Aug 2, 2022 · 1 comment

Comments

@esakhib
Copy link

esakhib commented Aug 2, 2022

I did something like this:

x,y = read_from_file()
my_pwlf = pwlf.PiecewiseLinFit(x, y)
my_pwlf.fitfast(breaks_num=15, pop=500)
x_out = np.linspace(min(x), max(x), num=10000)
y_out = my_pwlf.predict(x_out)

And then I calculated and saved all 15 slopes values in the file. Now, I want to load x, y and slopes, and get y_out, can I get this or must calculate fitfast again?
Also I have saved duration of each slope.

@cjekel
Copy link
Owner

cjekel commented Aug 3, 2022

This dumps the whole model (and data) https://jekel.me/piecewise_linear_fit_py/examples.html#model-persistence which you may or may not want to do.

These models don't really work with slopes, they work on model parameters (beta) and breakpoints. The difference between model parameters and slopes is how I formulate the piecewise problem. Take a look at #13 (comment) which save the beta and breakpoint values from a fitted model. After doing that predict call, it repopulates all the model parameters, and you can get the slopes from it.

Does this help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants