Closed SebastianHD closed 5 years ago
I had someone asking about this last week. Thank you for the simple code to implement this.
I don't really understand why the y-intercepts of the line segments are important. Slope are always internal to the model, but the y-intercepts are likely to be outside the model.
I take it this function should be called calc_intercepts, and the offsets should be stored as self.y_intercepts
Just to remind everyone that the beta parameters of the continuous piecewise linear function are all that is needed for prediction. These are the parameters solved from the least squares fit.
\mathbf{y}(x) = \begin{cases}
\beta_1 + \beta_2(x-b_1) & b_1 \leq x \leq b_2 \\
\beta_1 + \beta_2(x-b_1) + \beta_3(x-b_2) & b_2 < x \leq b_3 \\
\vdots & \vdots \\
\beta_1 + \beta_2(x-b_1) + \beta_3(x-b_2) + \cdots + \beta_{n_b+1}(x-b_{n_b-1}) & b_{n-1} < x \leq b_{n_b} \\
\end{cases}
Thanks for the explanation. I didn't realize the segments took on that form using the beta parameters. Still it seems convenient to have, in order to get a quick outside perspective of what the model looks like. I have no intuition for the beta parameters.
Now in the latest version of pwlf 0.3.2
The y-intercept of each line is stored in self.intercepts
https://github.com/cjekel/piecewise_linear_fit_py/commit/9ec846847f0d3adee60d717571a027cc76f71a11
You have a function to calculate slopes, but not offsets.