{"id":37614472,"url":"https://github.com/tsitsimis/constrainedlr","last_synced_at":"2026-01-16T10:28:33.337Z","repository":{"id":164910363,"uuid":"640324705","full_name":"tsitsimis/constrainedlr","owner":"tsitsimis","description":"Drop-in replacement of sklearn's  Linear Regression with coefficients constraints","archived":false,"fork":false,"pushed_at":"2024-05-05T12:54:58.000Z","size":652,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-06T15:10:13.500Z","etag":null,"topics":["constraints","elasticnet-regression","lasso-regression","linear-regression","machine-learning","ml","python-package","quadratic-programming","ridge-regression","sklearn-compatible"],"latest_commit_sha":null,"homepage":"https://tsitsimis.github.io/constrainedlr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsitsimis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-13T17:54:49.000Z","updated_at":"2024-05-12T20:04:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"be862ce2-7a08-4653-8a73-76d06bc56e54","html_url":"https://github.com/tsitsimis/constrainedlr","commit_stats":{"total_commits":37,"total_committers":1,"mean_commits":37.0,"dds":0.0,"last_synced_commit":"1fbed4bff4f234db99799509b70cb4c2b78fcad9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/tsitsimis/constrainedlr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsitsimis%2Fconstrainedlr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsitsimis%2Fconstrainedlr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsitsimis%2Fconstrainedlr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsitsimis%2Fconstrainedlr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsitsimis","download_url":"https://codeload.github.com/tsitsimis/constrainedlr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsitsimis%2Fconstrainedlr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constraints","elasticnet-regression","lasso-regression","linear-regression","machine-learning","ml","python-package","quadratic-programming","ridge-regression","sklearn-compatible"],"created_at":"2026-01-16T10:28:32.611Z","updated_at":"2026-01-16T10:28:33.319Z","avatar_url":"https://github.com/tsitsimis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Constrained Linear Regression\n\u003ca href=\"https://pypi.org/project/constrainedlr\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/constrainedlr?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/constrainedlr\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/constrainedlr.svg?color=%2334D058\" alt=\"Supported Python versions\"\u003e\n\u003c/a\u003e\n\nconstrainedlr is a drop-in replacement for `scikit-learn`'s `linear_model.LinearRegression` with the extended capability to apply constraints on the model's coefficients, such as signs and lower/upper bounds.\n\n## Installation\n```bash\npip install constrainedlr\n```\n\n## Example Usage\n\n### Coefficients sign constraints\n```python\nfrom constrainedlr import ConstrainedLinearRegression\n\nmodel = ConstrainedLinearRegression()\n\nmodel.fit(\n    X_train,\n    y_train,\n    coefficients_sign_constraints={0: \"positive\", 2: \"negative\"},\n    intercept_sign_constraint=\"positive\",\n)\n\ny_pred = model.predict(X_test)\n\nprint(model.coef_, model.intercept_)\n```\n\n### Coefficients range constraints\n```python\nfrom constrainedlr import ConstrainedLinearRegression\n\nmodel = ConstrainedLinearRegression()\n\nmodel.fit(\n    X_train,\n    y_train,\n    coefficients_range_constraints={\n        0: {\"lower\": 2},  # 1st coefficient must be 2 or higher\n        2: {\"upper\": 10},  # 3rd coefficient must be smaller than 10\n        3: {\"lower\": 0.1, \"upper\": 0.5},  # 4th coefficient must be between 0.1 and 0.5\n    },\n)\n\ny_pred = model.predict(X_test)\n\nprint(model.coef_)\n```\n\nSee more in the [documentation](https://tsitsimis.github.io/constrainedlr/)\n\n\n### Licence\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsitsimis%2Fconstrainedlr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsitsimis%2Fconstrainedlr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsitsimis%2Fconstrainedlr/lists"}