{"id":34103580,"url":"https://github.com/willbakst/pytorch-lattice","last_synced_at":"2026-03-10T18:06:45.129Z","repository":{"id":206317071,"uuid":"716225148","full_name":"willbakst/pytorch-lattice","owner":"willbakst","description":"A PyTorch implementation of constrained optimization and modeling techniques","archived":false,"fork":false,"pushed_at":"2024-05-10T19:12:32.000Z","size":1246,"stargazers_count":34,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-12-17T00:30:27.196Z","etag":null,"topics":["constrained-optimization","explainable-ai","explainable-ml","interpretable-ai","interpretable-ml","shape-constraints"],"latest_commit_sha":null,"homepage":"https://willbakst.github.io/pytorch-lattice/","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/willbakst.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-08T17:34:29.000Z","updated_at":"2025-11-11T16:32:27.000Z","dependencies_parsed_at":"2023-11-14T03:24:48.561Z","dependency_job_id":"9c9a54f6-580a-46fa-a244-00878cfd83bc","html_url":"https://github.com/willbakst/pytorch-lattice","commit_stats":null,"previous_names":["controlai/pytorch-lattice","willbakst/pytorch-lattice","mirascope/pytorch-lattice"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/willbakst/pytorch-lattice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willbakst%2Fpytorch-lattice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willbakst%2Fpytorch-lattice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willbakst%2Fpytorch-lattice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willbakst%2Fpytorch-lattice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willbakst","download_url":"https://codeload.github.com/willbakst/pytorch-lattice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willbakst%2Fpytorch-lattice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30346544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["constrained-optimization","explainable-ai","explainable-ml","interpretable-ai","interpretable-ml","shape-constraints"],"created_at":"2025-12-14T17:45:00.998Z","updated_at":"2026-03-10T18:06:45.121Z","avatar_url":"https://github.com/willbakst.png","language":"Python","readme":"# Getting Started with PyTorch Lattice\n\nA PyTorch implementation of constrained optimization and modeling techniques\n\n- **Transparent Models**: Glassbox models to provide increased interpretability and insights into your ML models.\n- **Shape Constraints**: Embed domain knowledge directly into the model through feature constraints.\n- **Rate Constraints (Coming soon...)**: Optimize any PyTorch model under a set of constraints on rates (e.g. FPR \u003c 1%). Rates can be calculated both for the entire dataset as well as specific slices.\n\n---\n\n[![GitHub stars](https://img.shields.io/github/stars/ControlAI/pytorch-lattice.svg)](https://github.com/ControlAI/pytorch-lattice/stargazers)\n[![Documentation](https://img.shields.io/badge/docs-available-brightgreen)](https://controlai.github.io/pytorch-lattice/)\n[![](https://github.com/ControlAI/pytorch-lattice/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/ControlAI/pytorch-lattice/actions/workflows/test.yml)\n[![GitHub issues](https://img.shields.io/github/issues/ControlAI/pytorch-lattice.svg)](https://github.com/ControlAI/pytorch-lattice/issues)\n[![Github discussions](https://img.shields.io/github/discussions/ControlAI/pytorch-lattice)](https:github.com/ControlAI/pytorch-lattice/discussions)\n[![GitHub license](https://img.shields.io/github/license/ControlAI/pytorch-lattice.svg)](https://github.com/ControlAI/pytorch-lattice/blob/main/LICENSE)\n[![PyPI version](https://img.shields.io/pypi/v/pytorch-lattice.svg)](https://pypi.python.org/pypi/pytorch-lattice)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pytorch-lattice.svg)](https://pypi.python.org/pypi/pytorch-lattice)\n\n---\n\n## Installation\n\nInstall PyTorch Lattice and start training and analyzing calibrated models in minutes.\n\n```sh\n$ pip install pytorch-lattice\n```\n\n## Quickstart\n\n### Step 1. Import the package\n\nFirst, import the PyTorch Lattice library:\n\n```py\nimport pytorch_lattice as pyl\n```\n\n### Step 2. Load data and fit a classifier\n\nLoad the UCI Statlog (Heart) dataset. Then create a base classifier and fit it to the data. Creating the base classifier requires only the feature names.\n\n```py\nX, y = pyl.datasets.heart()\nclf = pyl.Classifier(X.columns).fit(X, y)\n```\n\n### Step 3. Plot a feature calibrator\n\nNow that you've trained a classifier, you can plot the feature calibrators to better understand how the model is understanding each feature.\n\n```py\npyl.plots.calibrator(clf.model, \"thal\")\n```\n\n![Thal Calibrator](img/thal_calibrator.png)\n\n### Step 4. What's Next?\n\n-   Check out the [Concepts](concepts/classifier.md) section to dive deeper into the library and the core features that make it powerful, such as [calibrators](concepts/calibrators.md) and [shape constraints](concepts/shape_constraints.md).\n-   You can follow along with more detailed [walkthroughs](walkthroughs/uci_adult_income.md) to get a better understanding of how to utilize the library to effectively model your data. You can also take a look at [code examples](https://github.com/ControlAI/pytorch-lattice/tree/main/examples) in the repo.\n-   The [API Reference](api/layers.md) contains full details on all classes, methods, functions, etc.\n\n## Related Research\n\n- [Monotonic Kronecker-Factored Lattice](https://openreview.net/forum?id=0pxiMpCyBtr), William Taylor Bakst, Nobuyuki Morioka, Erez Louidor, International Conference on Learning Representations (ICLR), 2021\n- [Multidimensional Shape Constraints](https://proceedings.mlr.press/v119/gupta20b.html), Maya Gupta, Erez Louidor, Oleksandr Mangylov, Nobu Morioka, Taman Narayan, Sen Zhao, Proceedings of the 37th International Conference on Machine Learning (PMLR), 2020\n- [Deontological Ethics By Monotonicity Shape Constraints](https://arxiv.org/abs/2001.11990), Serena Wang, Maya Gupta, International Conference on Artificial Intelligence and Statistics (AISTATS), 2020\n- [Shape Constraints for Set Functions](http://proceedings.mlr.press/v97/cotter19a.html), Andrew Cotter, Maya Gupta, H. Jiang, Erez Louidor, Jim Muller, Taman Narayan, Serena Wang, Tao Zhu. International Conference on Machine Learning (ICML), 2019\n- [Diminishing Returns Shape Constraints for Interpretability and Regularization](https://papers.nips.cc/paper/7916-diminishing-returns-shape-constraints-for-interpretability-and-regularization), Maya Gupta, Dara Bahri, Andrew Cotter, Kevin Canini, Advances in Neural Information Processing Systems (NeurIPS), 2018\n- [Deep Lattice Networks and Partial Monotonic Functions](https://research.google.com/pubs/pub46327.html), Seungil You, Kevin Canini, David Ding, Jan Pfeifer, Maya R. Gupta, Advances in Neural Information Processing Systems (NeurIPS), 2017\n- [Fast and Flexible Monotonic Functions with Ensembles of Lattices](https://papers.nips.cc/paper/6377-fast-and-flexible-monotonic-functions-with-ensembles-of-lattices), Mahdi Milani Fard, Kevin Canini, Andrew Cotter, Jan Pfeifer, Maya Gupta, Advances in Neural Information Processing Systems (NeurIPS), 2016\n- [Monotonic Calibrated Interpolated Look-Up Tables](http://jmlr.org/papers/v17/15-243.html), Maya Gupta, Andrew Cotter, Jan Pfeifer, Konstantin Voevodski, Kevin Canini, Alexander Mangylov, Wojciech Moczydlowski, Alexander van Esbroeck, Journal of Machine Learning Research (JMLR), 2016\n- [Optimized Regression for Efficient Function Evaluation](http://ieeexplore.ieee.org/document/6203580/), Eric Garcia, Raman Arora, Maya R. Gupta, IEEE Transactions on Image Processing, 2012\n- [Lattice Regression](https://papers.nips.cc/paper/3694-lattice-regression), Eric Garcia, Maya Gupta, Advances in Neural Information Processing Systems (NeurIPS), 2009\n\n## Contributing\n\nPyTorch Lattice welcomes contributions from the community! See the [contribution guide](contributing.md) for more information on the development workflow. For bugs and feature requests, visit our [GitHub Issues](https://github.com/ControlAI/pytorch-lattice/issues) and check out our [templates](https://github.com/ControlAI/pytorch-lattice/tree/main/.github/ISSUE_TEMPLATES).\n\n## How To Help\n\nAny and all help is greatly appreciated! Check out our page on [how you can help](help.md).\n\n## Roadmap\n\nCheck out the our [roadmap](https://github.com/orgs/ControlAI/projects/1/views/1) to see what's planned. If there's an item that you really want that isn't assigned or in progress, take a stab at it!\n\n## Versioning\n\nPyTorch Lattice uses [Semantic Versioning](https://semver.org/).\n\n## License\n\nThis project is licensed under the terms of the [MIT License](https://github.com/ControlAI/pytorch-lattice/blob/main/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillbakst%2Fpytorch-lattice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillbakst%2Fpytorch-lattice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillbakst%2Fpytorch-lattice/lists"}