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

If you're not sure about the file name format, learn more about wheel file names.

ruleopt-1.1.4-cp313-cp313-win_amd64.whl (546.0 kB view details)

Uploaded CPython 3.13Windows x86-64

ruleopt-1.1.4-cp313-cp313-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

ruleopt-1.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ruleopt-1.1.4-cp313-cp313-macosx_11_0_arm64.whl (551.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ruleopt-1.1.4-cp313-cp313-macosx_10_13_x86_64.whl (562.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

ruleopt-1.1.4-cp312-cp312-win_amd64.whl (546.4 kB view details)

Uploaded CPython 3.12Windows x86-64

ruleopt-1.1.4-cp312-cp312-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ruleopt-1.1.4-cp312-cp312-macosx_11_0_arm64.whl (553.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ruleopt-1.1.4-cp312-cp312-macosx_10_13_x86_64.whl (564.3 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

ruleopt-1.1.4-cp311-cp311-win_amd64.whl (546.5 kB view details)

Uploaded CPython 3.11Windows x86-64

ruleopt-1.1.4-cp311-cp311-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

ruleopt-1.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ruleopt-1.1.4-cp311-cp311-macosx_11_0_arm64.whl (553.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ruleopt-1.1.4-cp311-cp311-macosx_10_9_x86_64.whl (563.8 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

ruleopt-1.1.4-cp310-cp310-win_amd64.whl (545.7 kB view details)

Uploaded CPython 3.10Windows x86-64

ruleopt-1.1.4-cp310-cp310-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ruleopt-1.1.4-cp310-cp310-macosx_11_0_arm64.whl (553.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ruleopt-1.1.4-cp310-cp310-macosx_10_9_x86_64.whl (563.8 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

ruleopt-1.1.4-cp39-cp39-win_amd64.whl (546.4 kB view details)

Uploaded CPython 3.9Windows x86-64

ruleopt-1.1.4-cp39-cp39-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

ruleopt-1.1.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ruleopt-1.1.4-cp39-cp39-macosx_11_0_arm64.whl (553.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ruleopt-1.1.4-cp39-cp39-macosx_10_9_x86_64.whl (564.6 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file ruleopt-1.1.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: ruleopt-1.1.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 546.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ruleopt-1.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3546ecf8e83cf64c1af5b795bbaf7e0b8336a5b7792d89b873d6fd4a675e0a98
MD5 37ba35b751316517e7a3a6c9f8ae3900
BLAKE2b-256 359c03a2cddd032c9a98a1d218c24e631e38101def014f1619672f6ef3e83bfa

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d08a472a474cb5be3ae45a9d49f1f8e262a6a9139f08e2ef860efaa666bed360
MD5 b7c6f177fda45d03708b10e1eb6fc5b5
BLAKE2b-256 586efb20f964e48a371666c528df0e7d0d738a63548e748498be4b71cf4b9719

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 59723d051354b3ca337517dcc9e4ddf4d734155b7126f66330ab02ad0f2694c3
MD5 288a512f3efe273f7d97145ac83686fd
BLAKE2b-256 f5bd652faa6faaf19e7da8d3669b1aa3ad3fbff7666c43ccc2bfd5fe4ccd2658

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59366057bcfb22af9ead70bcb56f09483441471286a5fceed541ba946579b248
MD5 1aa58ea5433318e6faad1d8a1e2d882c
BLAKE2b-256 ac30211f39158edefcc832a892583ee067ab0926bc2242cefdd091174c1ae2cc

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 87cee21f87a3d9a3f733e0c7f18b398d3f7b4834e99f3ceedfdcaf2af499b55f
MD5 52a8ecea9feca5a0f978cce7b713d988
BLAKE2b-256 446d20708ab9f0693256ec4da12e3233dbc0f7a156861984473a198033addcff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruleopt-1.1.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 546.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ruleopt-1.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e6ac763d6aca1ec43ac911b17b471e923a32bf9ded74c5238593405b147688eb
MD5 a1170781a1fcd9f302378e4b591a0940
BLAKE2b-256 7f3ca0dce2d01e2af245cdd3c30e77381b0b5e33224f9d1d08375268bf12e1df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 220c8d908b69144e7a344bf39ff51651b8e80f95f9e07e2bc6383e49f9a5b58a
MD5 ea0cf6300661415485d7f20efa96dae0
BLAKE2b-256 ec4d3a176786431ab82e1baef2a4345d56e5e0b76d2cf590a7bc761f76b3621d

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca328a126c4815d31eaa042ed78e9c5d7d3599206fecfaf076b47ec644604863
MD5 aad40b074b5b93212a209ae813e1e5e4
BLAKE2b-256 1dcfb477e127f2b3fd598393561aa95c06cf5bc433c1da91417111bf06a878d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48bb7887c88fba13d297c538765289d3ff25e11e786d95367e05a87aef602246
MD5 29396425f5e577301cce9476206b61db
BLAKE2b-256 d96e97154c06e89c80a318ef04ed0621e3190a802122d0427713e04aa4e5bf8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0150672289a5bb044a29bd6dbc59446c7c7050f73027b1cddbb17d14e7cc1a2c
MD5 855477a1db69a5045ba208e68ce1a210
BLAKE2b-256 4aa9fa58c79ed9219d2076b936e1ca7443a16a9c55418b29f005a138d894448e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruleopt-1.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 546.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ruleopt-1.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1db15e9b9fd7c14ef9d1b90184622363763e3fef4c8ec5373f07d0a2754bd74b
MD5 ae62e718010a65cfce60b4ab734c5b3f
BLAKE2b-256 497c2149bf1430f6d718436683dd9788e132973c3f9715a175da3a0828821341

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cf350e40d36c66144039ce66e2bc7caa0ff7aaf1e705b1170daa72ce3f1f02bf
MD5 4e615fdb70167d516c0106ef23f444cb
BLAKE2b-256 43a101af67850ec8b71357b55bc4b2d5df9819544e51ff28dd45d94bb340db81

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0db2d4c9a6c595eaa5de229dcdd9184a3509307a00166fdbcecaa252c221b42
MD5 6e50a7a2c4329756bdad4b4002b55d7f
BLAKE2b-256 70bdac2f64ad815e9fbd0057fe497647d5a9f2911d2a17adb02b2e4ad8700042

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2fc518b03091882b5989a9f38cf3561f8c8caacd5d2dfb901d66e5b9a4f5ae33
MD5 0a0026075e69caff801dd5d696696809
BLAKE2b-256 8278acb95ea0e9e991120310d5b51f1a27ce903b16f373e6e7703845145f14fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f44f4047501c90c875d2bd421122bbc2cbac1f74ca074781f73e5377e54c774c
MD5 d24bc28236846cfa3bc39c07367528fd
BLAKE2b-256 3ee80ab6a9164965bd6c9aeed008e6f9bd1fc73ad85d76c1820108be5deda4fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruleopt-1.1.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 545.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ruleopt-1.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9b28390db806b81ba06efe6c7b29f96f9f3ca0de01a03d40d92a57d77d8f05a3
MD5 f5db14948e625d8ee42b90c7afea3ae8
BLAKE2b-256 e04f6cb9f8c2803e50e4e95b5820b1b56c1634e576ce51ce26ed07327dddd0f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5555a02b2323296adb5c4ce3acbd92e2bb957549d7ba03076e434178140c47d8
MD5 fe52e53aba2d244f7136bb15123a513d
BLAKE2b-256 53bb0a9bc471b2e1ce43416ad7e7814dc18d6eb7e390f2644c06bae078839c39

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e79175de78b9757fc6f0ef9c5602f99ea9c7675498cd0847b5840190495bc1c
MD5 b12fec88821d73a97a79a65930371a6a
BLAKE2b-256 6da456ef03c0cbfd183c4c142a7a8c7ab1fb6a7bbfd278ce7462dbfea57d5fab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ea990e3aab0ab7477ce5f35fc371ccf71f4ec9080295f81614906727b27b03c
MD5 baa12f9f4f158c9e9e3a34ed1a57a88e
BLAKE2b-256 221cf90ff9a6d83f8c0ba9b47bbe46717a4e588707291cb802db1323a6bcd0cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 512b078a105483f75f62a249c53db6de0e2a7f4366da5c54c69fe39c32bc5591
MD5 5f796fd96fd261e98fcd73cba8218221
BLAKE2b-256 08257c05353e61667c32c01e62f84c2dfb4e55db79e18e13084be8bb7c3417e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ruleopt-1.1.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 546.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ruleopt-1.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c9e4aed170bd8c9117acf9923593946d5be77301d6f3c677d12f385fd33c8b81
MD5 9575c990e4c83f850f4bd39d25644d19
BLAKE2b-256 33c79d750eb683f0e3df6f0eba9dd9d6dd50e2ded2abc3d5e994113619cb2b91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cbd821750af596b8383b6d8c3ecd908d4b4befc151ba72bae6be28bd602fa5e8
MD5 0dcde7b89135e1704bb879825ae970e2
BLAKE2b-256 b82de7b4337f417e920fefec4c9bc87ac98088e8c408e66e0730f2dd0227b8cd

See more details on using hashes here.

File details

Details for the file ruleopt-1.1.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd730b47e49a9dba91b204f91dd4f4a89312efb547776cac31dbf51c66b58b15
MD5 a85f8546ccaa0fe4b544159684961f50
BLAKE2b-256 5ec99071827b88d7c8186ce0a5398c064adb9306aca3be6e2c3f5b8c228a4ebc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3370b23164f83cffd6907e5112d5263c0e146d6f6cdbd8c24ec57bb4c5a744bc
MD5 d7d31c838d73db1311f680737f677e62
BLAKE2b-256 49c7594e3c1b96477b6ff76259a5455af5c0adf4ad9a9f40b8acf813c76bdd0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ruleopt-1.1.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5248fdaa4fbd87f98bb639934249a47c11cd072ae1d36eda9645574939b12d18
MD5 9df8f7182f9dd9d201fb9f8b579ec65e
BLAKE2b-256 87b68b95a6146c65ed436b287f218df0176bf7c4a3888dc6cc2f802b04f4037c

See more details on using hashes here.

Supported by

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