Skip to content

Re-constructing Piecewise PWLF #106

@iiwolf

Description

@iiwolf

Hello, thanks for your hard work on this library, I've found it very useful! Issue #85 may be referencing this issue, but I would like to construct a PWFL piecewise curve from a modeled set of coefficients.

Essentially I'm creating a Kriging model to predict the coefficients and breakpoints required to construct the curve. For example with something simple like poly1d:

# Kriging model predicts coeffs and end time from model inputs <x>
coeffs,  t_end = coeff_model.predict(x)

# Create model
model = np.poly1d(coeffs)

# Construct input time vector and predict y response
t = np.arange(0,t_end,0.1)
y = model(t)

Is there a way to do this with PWFL? Maybe with setting betas and intercepts as mentioned #85? Or is that not available with polynomials? For example, I'll probably try to get something like this to work:

# Kriging model predicts coeffs and end time from model inputs <x>
betas, intercepts,  breaks = coeff_model.predict(x)

# Construct input time vector and predict y response
t = np.arange(0,breaks[-1],0.1)

# Create model with empty y
model = pwlf.PiecewiseLinFit(t, np.empty_like(t), degree=2)
model.beta = betas
model.intercept = intercepts
model.fit_breaks = breaks

y = model(t)

I've been able to successfully do this process with basic non-piecewise polynomial fits and my own PiecewisePolynomial class. But PWLF seems to be more robust so I'd like to use it!

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions