{"id":8605,"library":"ropwr","title":"RoPWR: Robust Piecewise Regression","description":"RoPWR (Robust Piecewise Regression) is a Python library that implements robust piecewise regression using convex optimization techniques. It provides a flexible framework to model non-linear relationships with segments, supporting various solvers via CVXPY. The current version is 1.2.0, with releases occurring every few months, primarily driven by feature additions, improvements, and dependency updates.","status":"active","version":"1.2.0","language":"en","source_language":"en","source_url":"https://github.com/guillermo-navas-palencia/ropwr","tags":["regression","piecewise","robust","optimization","convex-optimization","cvxpy","machine-learning","statistics"],"install":[{"cmd":"pip install ropwr","lang":"bash","label":"Install base package"},{"cmd":"pip install 'ropwr[all]' # Installs common CVXPY solvers like Clarabel, SCS, OSQP, ECOS","lang":"bash","label":"Install with all optional solvers"}],"dependencies":[{"reason":"Core numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Data manipulation, often used for input data.","package":"pandas","optional":false},{"reason":"Machine learning utilities, estimators, and data preprocessing.","package":"scikit-learn","optional":false},{"reason":"Convex optimization problem formulation and solving; core engine for RoPWR.","package":"cvxpy","optional":false},{"reason":"Default SOCP solver for CVXPY, recommended for performance.","package":"clarabel","optional":true},{"reason":"A conic-problem solver for CVXPY.","package":"scs","optional":true},{"reason":"An operator splitting solver for quadratic programs.","package":"osqp","optional":true}],"imports":[{"symbol":"RoPWR","correct":"from ropwr import RoPWR"}],"quickstart":{"code":"import numpy as np\nfrom ropwr import RoPWR\n\n# Generate some synthetic data\nnp.random.seed(0)\nX = np.linspace(0, 10, 100).reshape(-1, 1)\ny = np.where(X < 5, 2 * X, -X + 15).flatten() + np.random.normal(0, 1, 100)\n\n# Initialize and fit the RoPWR model with 2 segments\nmodel = RoPWR(n_segments=2, solver='Clarabel', random_state=42)\nmodel.fit(X, y)\n\n# Make predictions\ny_pred = model.predict(X)\n\nprint(f\"Predicted y for X[0]: {y_pred[0]:.2f}\")\nprint(f\"R^2 score: {model.score(X, y):.2f}\")","lang":"python","description":"This quickstart demonstrates how to instantiate, fit, and predict with the `RoPWR` model. It creates a simple dataset with two linear segments and fits a `RoPWR` model with two segments. The 'Clarabel' solver is specified, which is efficient for SOCP problems."},"warnings":[{"fix":"Upgrade ropwr to version 1.2.0 or higher. If unable to upgrade ropwr, downgrade scikit-learn to <1.6.","message":"Incompatibility with scikit-learn 1.6+ due to `force_all_finite` deprecation.","severity":"gotcha","affected_versions":"<1.2.0"},{"fix":"Upgrade ropwr to version 0.4.0 or higher. If using an older version, try specifying a different solver (e.g., `solver='Clarabel'` or `solver='SCS'`) or use `solver='auto'`.","message":"Older versions of RoPWR might experience OSQP solver convergence issues, especially with complex problems.","severity":"gotcha","affected_versions":"<0.4.0"},{"fix":"Upgrade ropwr to version 1.0.0 or higher to utilize the `max_iter` parameter.","message":"The `max_iter` parameter for controlling solver iterations was introduced in v1.0.0. Attempting to use it with older versions will raise an AttributeError.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure ropwr is version 1.0.0 or higher if your application requires these features. Refer to the documentation for how to enable continuous derivatives or specific extrapolation methods.","message":"Key features like enforcing continuous derivatives at split points and extrapolation methods were added in v1.0.0.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade `ropwr` to `1.2.0` or higher: `pip install --upgrade ropwr`. Alternatively, if you cannot upgrade `ropwr`, downgrade `scikit-learn` to a version prior to 1.6: `pip install 'scikit-learn<1.6'`.","cause":"This error occurs when an older version of `ropwr` (prior to 1.2.0) is used with `scikit-learn` version 1.6 or newer. `scikit-learn` deprecated `force_all_finite` in favor of `ensure_all_finite`.","error":"TypeError: force_all_finite received a sparse matrix... Expected an array, got a sparse matrix."},{"fix":"Upgrade `ropwr` to version 1.0.0 or higher: `pip install --upgrade ropwr`. If you cannot upgrade, remove the `max_iter` parameter from your `RoPWR` instantiation.","cause":"You are attempting to set the `max_iter` parameter when initializing or fitting a `RoPWR` model, but your `ropwr` library version is older than 1.0.0.","error":"AttributeError: 'RoPWR' object has no attribute 'max_iter'"},{"fix":"Try explicitly specifying a different solver in the `RoPWR` constructor, for example, `RoPWR(..., solver='Clarabel')` or `RoPWR(..., solver='SCS')`. Ensure you have the necessary solvers installed (e.g., `pip install 'ropwr[all]'`). For detailed debugging, set `verbose=True` in the `RoPWR` constructor.","cause":"The default or specified CVXPY solver (OSQP in this case) failed to converge or solve the optimization problem. This can be due to problem conditioning, solver limitations, or specific data characteristics.","error":"cvxpy.error.SolverError: Solver 'OSQP' failed. Try another solver or set verbose=True for more details."},{"fix":"Verify that `ropwr` is correctly installed (`pip show ropwr`). Ensure the import statement is exactly `from ropwr import RoPWR`. If you've just installed it, restarting your interpreter or IDE might resolve module caching issues.","cause":"This usually means the `RoPWR` class is not found in the `ropwr` package. This could be a typo in the import statement or an issue with the installation.","error":"ImportError: cannot import name 'RoPWR' from 'ropwr'"}]}