{"library":"piecewise-regression","title":"Piecewise Regression","description":"Piecewise-regression is a Python library for performing segmented (or piecewise) regression analysis. It allows fitting models with one or more breakpoints, identifying where the relationship between independent and dependent variables changes. The current version is 1.5.0, with a moderate release cadence focused on statistical improvements and convenience features.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install piecewise-regression"],"cli":null},"imports":["from piecewise_regression import PiecewiseRegression"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom piecewise_regression import PiecewiseRegression\nimport matplotlib.pyplot as plt\n\n# Generate some synthetic data with a known breakpoint\nx = np.linspace(0, 100, 500)\ny = np.concatenate([\n    -0.1 * x[x <= 50] + 10,\n    0.5 * x[x > 50] - 20\n]) + np.random.normal(0, 1, 500)\n\n# Initialize and fit the model with one breakpoint\npw_fit = PiecewiseRegression(x, y, n_breakpoints=1)\npw_fit.fit()\n\n# Print a summary of the fit\npw_fit.summary()\n\n# Plot the fit (requires matplotlib to show)\nfig, ax = pw_fit.plot_fit(show=False)\nax.set_title('Piecewise Regression Fit')\nplt.show()","lang":"python","description":"This quickstart demonstrates how to generate synthetic data with a breakpoint, initialize the `PiecewiseRegression` model, fit it to the data, and then visualize the results. It highlights the core workflow from data preparation to model interpretation.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}