Skip to main content

Optimization-Based Rule Learning for Classification

Project description

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

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 Gurobi, CPLEX and OR-Tools.

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 ORToolsSolver

# 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 = ORToolsSolver()
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

ruleopt-1.1.2-cp312-cp312-win_amd64.whl (552.7 kB view details)

Uploaded CPython 3.12Windows x86-64

ruleopt-1.1.2-cp312-cp312-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

ruleopt-1.1.2-cp312-cp312-musllinux_1_2_i686.whl (1.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

ruleopt-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ruleopt-1.1.2-cp312-cp312-macosx_11_0_arm64.whl (557.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ruleopt-1.1.2-cp312-cp312-macosx_10_13_x86_64.whl (570.1 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

ruleopt-1.1.2-cp311-cp311-win_amd64.whl (552.9 kB view details)

Uploaded CPython 3.11Windows x86-64

ruleopt-1.1.2-cp311-cp311-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

ruleopt-1.1.2-cp311-cp311-musllinux_1_2_i686.whl (1.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

ruleopt-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ruleopt-1.1.2-cp311-cp311-macosx_11_0_arm64.whl (555.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ruleopt-1.1.2-cp311-cp311-macosx_10_9_x86_64.whl (568.0 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

ruleopt-1.1.2-cp310-cp310-win_amd64.whl (552.9 kB view details)

Uploaded CPython 3.10Windows x86-64

ruleopt-1.1.2-cp310-cp310-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

ruleopt-1.1.2-cp310-cp310-musllinux_1_2_i686.whl (1.5 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ i686

ruleopt-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ruleopt-1.1.2-cp310-cp310-macosx_11_0_arm64.whl (555.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ruleopt-1.1.2-cp310-cp310-macosx_10_9_x86_64.whl (568.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

ruleopt-1.1.2-cp39-cp39-win_amd64.whl (554.1 kB view details)

Uploaded CPython 3.9Windows x86-64

ruleopt-1.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

ruleopt-1.1.2-cp39-cp39-musllinux_1_2_i686.whl (1.5 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ i686

ruleopt-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ruleopt-1.1.2-cp39-cp39-macosx_11_0_arm64.whl (556.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ruleopt-1.1.2-cp39-cp39-macosx_10_9_x86_64.whl (569.3 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file ruleopt-1.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: ruleopt-1.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 552.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for ruleopt-1.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c870c10b0c4ecdf49b26a4533d6f62f865f76632292f79852f6ea812ca9740cd
MD5 b8270f719decbfd2acbe3c145c0d9501
BLAKE2b-256 6d0ce3c5333ebe5e5e44d1bbd5e05c61240994f31337cc66af2b5b568d07b091

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a87054ccbb04fa47292d745b5fa2d6909f133ac6f1543aba69ae243c3708815c
MD5 8477aa1dc5d841dd819698de84975982
BLAKE2b-256 bb9372336112bd7863de31d9998c30d3663abab0cc7be559b0596efac57d588d

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 6b500d85d7a871c93631371a61861a0e80253a5b14c03235e944f8f35cac3a21
MD5 15480974f9d09294f32fafda8e6085b3
BLAKE2b-256 9396bd1c1fc180cf013d2d7377760f874c88db6b942dabb8081ecaf1df54c24a

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e481ef8aa59b9ff6ad77ac00e0b616adba0f172f1a8e3898c6d318508f77f7e
MD5 9ec58fe4f03c7ee8690120a4b1373ab1
BLAKE2b-256 16d77c1a7d69a75f1f7e383871b3caf4a2edd7d1fd1a52e2e6a1098fddea1ed5

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 212802adbfca2b00c03f8a0c8b6ebba0733bcadb6e1d24cf2a0352d616b6ed4d
MD5 24a4dbbd5976071247a6b3b544995115
BLAKE2b-256 b897efecf1342f684d34a96289b35fb71bd0676c7b19a6b91be65b8c3f701770

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 237c3c9f7d1020fd9f1385e088fe244228af2f0c8c213b26e6c9cb4da6a49c3d
MD5 4b4557f819126d6e3fe56e245415faea
BLAKE2b-256 8d638fd902081bae13d478a88ed33266b9b1a1398dc0b1738ce387911474f761

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: ruleopt-1.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 552.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for ruleopt-1.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 aacb53ef144c08b1025b52e40793f032de82202f30f8f25ad824a04c0a8a7da3
MD5 ff32e209f183a4f4d782b3b35aa8e391
BLAKE2b-256 44daa60dc0930f26979733f903224ee5de11387c95b799c2f8904f108f9c0354

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 748313c333c7fa3083ab74e786aaffe3fd8ebd265bdd7f69abeb4500a8ddba12
MD5 c7da408a1ce8f35559ff276223bce3db
BLAKE2b-256 5f52ab5fc5d7a418fa1a0dcb2c88d8e01a8c8719650b4210ab5451a81f8be7bc

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e8109be589f08c2ea9f640bd65c832e1e091b8c47a5bcd025c7d55e9673897be
MD5 7be094ad0ea5a28a8d3d420d3f2bbfea
BLAKE2b-256 fea22e4e2f80a7576a6530efab2e2a361f1197e8df11e5b3c98dbed5f86f42a3

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0bfefd4ade7f766608988cb33280dda5db606eea45d69b5986bbf9000b8ec2e3
MD5 49fd38ac0728d611b8946082f9234afe
BLAKE2b-256 76c3dfc6b5bcecb6915d835077d55e4ed516c703b14951048a814615941597c7

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 003740fd3436e40c303b67efb6f0a54379f28943b237961a678670ec17b5e8a1
MD5 774552e4938091bc907507233eb5b42f
BLAKE2b-256 5214a4194abff90506a44ad68c1f607570868246a7921615def8e9ec0959c676

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 24ce35cc56b35871747565bc354adcc79a0bf761581157fa0bde22abc1c476bf
MD5 457fb6b16f9a3dbefb1305289a3fb8cd
BLAKE2b-256 a35fc569ecc4003228ae7406368cb81dc4077a7bcf82cb2af234d49aa3f9291f

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: ruleopt-1.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 552.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for ruleopt-1.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3841b9f27c2cb4a8df79c514a71ffb109115e9be00ca8b6b62cc5a3fdb9dc1c8
MD5 5ad3c878163bd1fb0567f5bd5eebf47a
BLAKE2b-256 691bd279d008a9bf535654e19b0626785a9469f8fb8d3ea1759a278f10b3eee8

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2767a4f1fa91d15f4e14547eaeb34ead5a98c2c19369376f7a46fe3bf94342b6
MD5 7ca4d50c2e1906c7ec89a84dbc2dfa8c
BLAKE2b-256 18df1afb748c9f5487d19bc15e247605a44147f2c3caa4c84563b9601fa5fa05

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp310-cp310-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp310-cp310-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 763bebd0e4ca639311285044c6775af0d7bb1f6efedd7f435fe98f8925d4add5
MD5 c21eaa1b3402c48abce5df5ceb067875
BLAKE2b-256 e458b2db19702da31e212dce1a07d1516586b30144d97aa651e4e1c878a47a8e

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3cf5b89a59a8a6c77ca374fa5fa71c4c53999d9f6833723aa3c0a5146a6f019
MD5 9c79ff59b8f8479a3e592d537c9c05ac
BLAKE2b-256 8985fe1f9b9457e60a0057d1819fef82cd5dc547554c0776d3c1e4237180eed0

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90d173ec842a42705d620f4434003373d0bfb45d3b4fa4e27e678ede9d2b3342
MD5 1ae4df68dfcd8b335248ad6c7071c088
BLAKE2b-256 2e7e2018f8c013d561518b4bca95b669cd37af3abde4251ce373f6f47a94ce0e

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 be956de6f80b1430084b4b1b3da1c55f9d5e668f5997aa3fe083d25704254b82
MD5 a8aaf34b73bd43980c212baf759405fa
BLAKE2b-256 c34825eb3ffe9427bfcf887a202ea65ed78c1151e52e04581cf5c42a99063c35

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ruleopt-1.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 554.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for ruleopt-1.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 dab90e0dc4eebf30175c98dbbff8c7319a77d8d3bfdc791b2d4da85f72944c9e
MD5 9411f184e979b01a2ec713381a4f03c4
BLAKE2b-256 f243066281fba1edc2911426e6c963c88c6f3efca46c9d995968dfbacf5fbc5f

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e907fdf1de1c166b40b2ac41168d7759c082a15ea9ab81d4093df602b4d86101
MD5 4b822524a1ad9cef43bb4022a15a61e0
BLAKE2b-256 cba4e04d84365ae9856c43c476140cf07f4c57b3d7e251463c88480f175ed5d0

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp39-cp39-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp39-cp39-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 432211a9c018f11af3bcb8b4f40b08b6c1a9b911f432b8dfffe567999c968911
MD5 043395c95d96476eab80f7891d4d7e6d
BLAKE2b-256 9d50f2428442995ea8598eb318352f427fd0cc134711723327f388dae38bbeef

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fee3c97d425d86573c0c7fd5839d19492ce44a0f1ef2b6dde231e46383eafb9a
MD5 b42b3d6f5bdda84a1400fc12bbc38067
BLAKE2b-256 29a6b348e402586bae9dadf3eabcf73d0a6f74a09a5f172646b66d18ce879dee

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f6e619a52349b1ad25ccee735181a95f1313c1f5e2d7a36467d2a6ca245547b
MD5 e25aed93bc30a885d806f8ecc783e47e
BLAKE2b-256 575e30acd7ce125abd9fc66ab8997d5e4de2f0b11dbf775d526227d604cb87db

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.2-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fed85d9187ac15238abd30023d4ba4d9d9a16277470a97b2da137da6b5cdefae
MD5 e5470b3bc6806666e170624b326ebd7c
BLAKE2b-256 a6424ee92c41a04c44bd3ba499fb98de55c18f8c518987040c60bf8998d7c2e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page