-
Notifications
You must be signed in to change notification settings - Fork 62
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
Coefficient access #84
Comments
The model parameters that this libraries finds are If you are working with linear segments, If you are working with high degrees, then things get complicated. One thing that doesn't help is my undocumented assembly process. I construct the matrix from left to right starting from the 0th degree, then the 1st for all line segments, and so forth. I agree that I don't want to add sympy as a requirement as I did here #44 which I was using to crudely sum all of the correct coefficients from the previous (ie making sure the linear segments remain with the linear segments, and so forth). A better approach would be a single method, that 1) grabbed all of the coefficients for each line 2) summed up the coefficients to evaluate individual lines. for instance my previous sympy work, could be modified by something like this (I have not ran this code, but this is what I was thinking) def get_symbolic_eqn(pwlf_, segment_number):
if pwlf_.degree < 1:
raise ValueError('Degree must be at least 1')
if segment_number < 1 or segment_number > pwlf_.n_segments:
raise ValueError('segment_number not possible')
# assemble degree = 1 first
for line in range(segment_number):
my_1st_term = []
if line == 0:
my_zero_term = pwlf_.beta[0] + (pwlf_.beta[1])*(x-pwlf_.fit_breaks[0])
else:
my_1st_term.append(pwlf_.beta[line+1])*(x-pwlf_.fit_breaks[line]))
# assemble all other degrees
if pwlf_.degree > 1:
# arbitrary degree not supported
my_2nd_term = []
for k in range(2, pwlf_.degree + 1):
for line in range(segment_number):
beta_index = pwlf_.n_segments*(k-1) + line + 1
my_2nd_term.append((pwlf_.beta[beta_index])*(x-pwlf_.fit_breaks[line])**k)
return sum(my_zero_term), sum(my_1st_term), sum(my_2nd_term) I think this just illustrates how the terms are summed. A better approach would populated the indices of interest, then use numpy slicing to grab them from |
The library is awesome. However not being able to easily access the coefficients is a huge problem for some applications.
I saw this #44 got resolved but requires installing other packages, and is not an 'out of the box' solution.
The text was updated successfully, but these errors were encountered: