Skip to main content

RuleOpt

Optimization-Based Rule Learning for Classification

RuleOpt is an optimization-based rule learning algorithm designed for classification problems. Focusing on scalability and interpretability, RuleOpt utilizes linear programming for rule generation and extraction. An earlier version of this work is available in our journal paper.

The Python library ruleopt is capable of extracting rules from ensemble models, and it also implements a novel rule generation scheme. The library ensures compatibility with existing machine learning pipelines, and it is especially efficient for tackling large-scale problems.

Here are a few highlights of ruleopt:

  • Efficient Rule Generation and Extraction: Leverages linear programming for scalable rule generation (stand-alone machine learning method) and rule extraction from trained random forest and boosting models.
  • Interpretability: Prioritizes model transparency by assigning costs to rules in order to achieve a desirable balance with accuracy.
  • Integration with Machine Learning Libraries: Facilitates smooth integration with well-known Python libraries scikit-learn, LightGBM, and XGBoost, and existing machine learning pipelines.
  • Extensive Solver Support: Supports a wide array of solvers, including HiGHS, Gurobi and CPLEX.

Installation

To install ruleopt, use the following pip command:

pip install ruleopt

Usage

To use ruleopt, you need to initialize the ruleopt class with your specific parameters and fit it to your data. Here's a basic example:

from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris

from ruleopt import RUGClassifier
from ruleopt.rule_cost import Gini
from ruleopt.solver import HiGHSSolver

# Set a random state for reproducibility
random_state = 42

# Load the Iris dataset
X, y = load_iris(return_X_y=True)

# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=random_state
)

# Define tree parameters
tree_parameters = {"max_depth": 3, "class_weight": "balanced"}

solver = HiGHSSolver()
rule_cost = Gini()

# Initialize the RUGClassifier with specific parameters
rug = RUGClassifier(
    solver=solver,
    random_state=random_state,
    max_rmp_calls=20,
    rule_cost=rule_cost,
    **tree_parameters,
)

# Fit the RUGClassifier to the training data
rug.fit(X_train, y_train)

# Predict the labels of the testing set
y_pred = rug.predict(X_test)

Documentation

For more detailed information about the API and advanced usage, please refer to the full documentation.

Contributing

Contributions are welcome! If you'd like to improve ruleopt or suggest new features, feel free to fork the repository and submit a pull request.

License

ruleopt is released under the BSD 3-Clause License. See the LICENSE file for more details.

Release files for ruleopt 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for ruleopt 1.2.1
File
ruleopt-1.2.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
ruleopt-1.2.1-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
ruleopt-1.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
ruleopt-1.2.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
ruleopt-1.2.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
ruleopt-1.2.1-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
ruleopt-1.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
ruleopt-1.2.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
ruleopt-1.2.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
ruleopt-1.2.1-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
ruleopt-1.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
ruleopt-1.2.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
ruleopt-1.2.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
ruleopt-1.2.1-cp310-cp310-musllinux_1_2_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.2+ x86-64 Details
ruleopt-1.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
ruleopt-1.2.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 16.9 MB

Release files / ruleopt-1.2.1-cp313-cp313-win_amd64.whl

Download URL ruleopt-1.2.1-cp313-cp313-win_amd64.whl
Size 568.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
764a2758d6ffe62d6337ba3003a52f470cf7621ca83340cafe8e9565770013ac
BLAKE2b-256 checksum
How to use checksums
c82a708383f2ea28a763a4664744fc1ca6654e179cae3a690cd745c32f96750b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL ruleopt-1.2.1-cp313-cp313-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
6ef156371a31d13c166f5e64944d603d3672b2f4558451805bb9fbed4b08b0d6
BLAKE2b-256 checksum
How to use checksums
4b6b7b41b665f7836f32169ef4dad1cb490cb5eb279c100680bd666b77570d79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL ruleopt-1.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2fd2e410db98e34f714bd222288106bc245fd2358e4a1851c6fac9d86b4907a1
BLAKE2b-256 checksum
How to use checksums
8bbfbe39e33910c104d887e9ad0c4d30791298a7e992b0945b55e145bc7f7874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL ruleopt-1.2.1-cp313-cp313-macosx_11_0_arm64.whl
Size 570.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7dcdbfa3769369f29acf8c6ebe156b2a1144f90bd27f2bf801f6a88f6fbc5a63
BLAKE2b-256 checksum
How to use checksums
c54a5a8af1018c84b0e388c64f6631ec69aa01c348fe3e12445056d24e4a9ab7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp312-cp312-win_amd64.whl

Download URL ruleopt-1.2.1-cp312-cp312-win_amd64.whl
Size 569.0 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6f2d13de9b218aaaf1154d23cbffcd598a5da187a306e9cb130a0ed3c8ab345f
BLAKE2b-256 checksum
How to use checksums
a9e1c44a4f9c2e9156c78ccd6972990958e36a966a2e8123f1c06cccd006637e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL ruleopt-1.2.1-cp312-cp312-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
b9b0e14479590fe87e59f3620390e7fecc408d7f38d1bc4b578a1334a5ea4181
BLAKE2b-256 checksum
How to use checksums
b18ac40442e206a3556cd561d636b47bf6401bbd4c59e5af4199da4d2c8d45b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL ruleopt-1.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
401fc58d684eb87dd61eba5dc35aa2394c649f75ef2143bc879c11cf41772d7c
BLAKE2b-256 checksum
How to use checksums
53569569653486e0685ee0ed578617464ed19ddcd0171cf0770ee0603f93b3db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL ruleopt-1.2.1-cp312-cp312-macosx_11_0_arm64.whl
Size 571.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
545deb87f3d8fc33fb6d9bc2f6c14c492652bbec6c4a8bee9c622edfef3c9380
BLAKE2b-256 checksum
How to use checksums
b6ddcb950fc27378cf81612657b7bebdfe2e78d43c86a8b1d3d0d6a899cbf144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp311-cp311-win_amd64.whl

Download URL ruleopt-1.2.1-cp311-cp311-win_amd64.whl
Size 568.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
afcd1f98ee7101d17c9997754a1074be07c848a2a4a3855b1f0a94c90d503670
BLAKE2b-256 checksum
How to use checksums
5595d1230a2ad65db3a746a2731e0812109c8523ed87867e077a8d988f2c9d8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL ruleopt-1.2.1-cp311-cp311-musllinux_1_2_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
aec9cc7f07504b0c62c35ea2baedab75024bff4b886d2d51f4b5c9f7ebd41afb
BLAKE2b-256 checksum
How to use checksums
8933d10a83d051a799a1469e633c8e939fc1b7e5ad08452d3aead8827c6f4ba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL ruleopt-1.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a3542e7c088b7ab0c7063b3443ee2be72ac8afcd93c6e737cc3d213d38cb725f
BLAKE2b-256 checksum
How to use checksums
f4cea33123f010e5146436c9fb4cb7992b6e0c3ba56a856b6924e949d5cb4f52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL ruleopt-1.2.1-cp311-cp311-macosx_11_0_arm64.whl
Size 572.4 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
40111edbb27e8d84b54a6c53d94b0544ab2cab9cb963bf2fe35fd4624fce9feb
BLAKE2b-256 checksum
How to use checksums
c2b528b1b00c70c063926c0fcea6cd5c14d6101e78f038cf54c51ec5821e8a4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp310-cp310-win_amd64.whl

Download URL ruleopt-1.2.1-cp310-cp310-win_amd64.whl
Size 568.8 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
0f5c934be24cb11f57453a885ecd655659e6f064ec73ee41de9e606b629a63ec
BLAKE2b-256 checksum
How to use checksums
42aa773a3585b9da1e255e262af914aeb82eae837bb878d65939272c612ba6af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ruleopt-1.2.1-cp310-cp310-musllinux_1_2_x86_64.whl

Download URL ruleopt-1.2.1-cp310-cp310-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
e5c66ab5ba10de36010626ff8736d218b48fb095aa79aeb72ba2dcafda39888c
BLAKE2b-256 checksum
How to use checksums
19faf5e2c648592e11e6397be481cbf29de46be4ddc87b1d1c107833bbe6ca46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL ruleopt-1.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c447abc4ef35f5b20a3d83fd1d5f6a59dd4607a705402cc68be9ab6073c3c91f
BLAKE2b-256 checksum
How to use checksums
6fb7fef3a586fb3c15a39887c5a7c4e8ec72ea6a435c5d20c214283222b6af72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / ruleopt-1.2.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL ruleopt-1.2.1-cp310-cp310-macosx_11_0_arm64.whl
Size 573.5 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
83f8ef7f2b67efb0166280e4af5e082c26df841481b01d7f4fc22b45a9ff9ca7
BLAKE2b-256 checksum
How to use checksums
77b1e9b66c0b310afeacc94cc567563fcd91f9095a38ead6b85204fcbfbe458f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

1.2.1 This release

16 release files

1.2.0

16 release files

1.1.2

24 release files

1.0.1

24 release files

1.0.0

24 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page