Giter Club home page Giter Club logo

pytorch-lattice's Introduction

Getting Started with PyTorch Lattice

A PyTorch implementation of constrained optimization and modeling techniques

  • Transparent Models: Glassbox models to provide increased interpretability and insights into your ML models.
  • Shape Constraints: Embed domain knowledge directly into the model through feature constraints.
  • Rate Constraints (Coming soon...): Optimize any PyTorch model under a set of constraints on rates (e.g. FPR < 1%). Rates can be calculated both for the entire dataset as well as specific slices.

GitHub stars Documentation GitHub issues Github discussions GitHub license PyPI version PyPI pyversions


Installation

Install PyTorch Lattice and start training and analyzing calibrated models in minutes.

$ pip install pytorch-lattice

Quickstart

Step 1. Import the package

First, import the PyTorch Lattice library:

import pytorch_lattice as pyl

Step 2. Load data and fit a classifier

Load 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.

X, y = pyl.datasets.heart()
clf = pyl.Classifier(X.columns).fit(X, y)

Step 3. Plot a feature calibrator

Now that you've trained a classifier, you can plot the feature calibrators to better understand how the model is understanding each feature.

pyl.plots.calibrator(clf.model, "thal")

Thal Calibrator

Step 4. What's Next?

  • Check out the Concepts section to dive deeper into the library and the core features that make it powerful, such as calibrators and shape constraints.
  • You can follow along with more detailed walkthroughs 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 in the repo.
  • The API Reference contains full details on all classes, methods, functions, etc.

Related Research

Contributing

PyTorch Lattice welcomes contributions from the community! See the contribution guide for more information on the development workflow. For bugs and feature requests, visit our GitHub Issues and check out our templates.

How To Help

Any and all help is greatly appreciated! Check out our page on how you can help.

Roadmap

Check out the our roadmap 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!

Versioning

PyTorch Lattice uses Semantic Versioning.

License

This project is licensed under the terms of the MIT License.

pytorch-lattice's People

Contributors

willbakst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pytorch-lattice's Issues

Enable Multi-Unit Inputs For Numerical And Categorical Calibrators


About:

Add multi-unit capabilities to numerical and categorical calibration layers.


Is your feature request related to a problem? Please describe.
As we build up the PyTorch Lattice Library, we will be implementing optimizations for the basic Lattice model which will require it to handle multiple units (RTL and Kronecker factored lattices). As a prerequisite, we will need the calibrators to accept multi-unit inputs.

Describe the solution you'd like
A refactoring of categorical_calibrator and numerical_calibrator classes to include multi unit functionality.

Describe alternatives you've considered
N/A

Additional context
N/A

Implement Random Tiny Lattices Layer


About:

Add a module that implements the optimized random tiny lattices layer.


Is your feature request related to a problem? Please describe.
Lattices can only handle so many features, so to combat this one technique is to use an ensemble of lattices that each operate on a subset of the features. The RTL layer optimizes the construction and calling of this ensemble by using the multi-unit functionality of the Lattice layer to parallelize the computation of input subsets with the same constraint structure.

Describe the solution you'd like
A torch.Module that implements the random tiny lattices functionality as a layer that can be used to build a CalibratedLatticeEnsemble.

Describe alternatives you've considered
N/A

Additional context
N/A

Keypoints inputs issue for learned interiors (Numerical Calibrator)


Describe the bug:

keypoints_inputs() method does not properly update, and instead runs on the previous iteration of keypoints constructed during forward pass.


To Reproduce
Steps to reproduce the behavior:

  1. Create a numerical calibrator with learned input keypoints
  2. Train the module on a few examples
  3. call calibrator.keypoints_inputs()
  4. Return value will be from the values from before the final training step.

Expected behavior
The final training step updates should be properly referenced. When using learned input keypoints, the keypoints_inputs function should generate the input keypoints directly from the logits.

Additional context
N/A

Learned Interior Input Keypoints For Numerical Calibrators


About:

Sometimes learned input keypoints can enable learning a better function because the calibrator is more flexible. This is especially true for output calibrators where you can't initialize based on quantiles (and learning input keypoints during training could be valuable compared to e.g. uniformly initialized keypoints).


Is your feature request related to a problem? Please describe.
Not a problem, just an enhancement.

Describe the solution you'd like
Enable learned interior keypoints for numerical calibrators through a constructor argument for input keypoint type.

Describe alternatives you've considered
None, this is the known implementation.

Additional context
N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.