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
, andXGBoost
, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for ruleopt-1.0.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6ef1e82701ae6012167002b982717ec22d4395f1864e2ec81fd57df416954d6 |
|
MD5 | f383b914831b8e0930cb49a880845b9f |
|
BLAKE2b-256 | 89312c68d1de022cc25ab4a9c708df206d1d5b011d2ea867d8b785f4d107d391 |
Hashes for ruleopt-1.0.1-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3272465f6b1a0df8b9e764d2492977fc7fe15456dbc3d9d1623195bbc613c7c4 |
|
MD5 | 73db2b1e007f5183b097099fd0441867 |
|
BLAKE2b-256 | ad68779aeb637f726898e2350833ea1e417208abdfef24a431c8afd31b1beb86 |
Hashes for ruleopt-1.0.1-cp312-cp312-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6021cd9427292243ca2775f365866dae71f5ce21d11b26e7149e5f0a9526f87 |
|
MD5 | af74e9d0bd752473ae2b88e89c2502d1 |
|
BLAKE2b-256 | 0366abf55140d420bb46599dd2c4e606fe610f7e97909a1e3a780420e8de5eba |
Hashes for ruleopt-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 712ea60af5c19cc5a2b402d1609b84d7ffc60d5b9ac8f9c09cbfde69ba2e270d |
|
MD5 | fdba66f42edfd07419aa2b1f6130eb3c |
|
BLAKE2b-256 | 6e56ae528ddca30e25ed5c38a2d2b50d1457c0c426340efc65afc0c0e10a1a72 |
Hashes for ruleopt-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94f7ce213882e10992f1bf713058e1bffd34d9ae3f1c23a1c6b40b133d59f30a |
|
MD5 | 5f9d4d315efd6ec7efa237b215d1b1f8 |
|
BLAKE2b-256 | 1a7fe9f20a70759e41438500328c906f936044efe8d77866097dd1c193299bb3 |
Hashes for ruleopt-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0d89c21a91c80ab1807c4b5228746edbacd0efded7834761eb78036c7b958d0 |
|
MD5 | 74c941400ec3580929fed2687e53688e |
|
BLAKE2b-256 | ede1b1ae989b7856ec1167f4b401b64cfae58c461383d2d559c87259a25a8660 |
Hashes for ruleopt-1.0.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53fb2c6e90004a449a4c8fe7a77e930aea802fa13d315180937e36b0571aab56 |
|
MD5 | 885bb8cf8f35a638158fabd1b57ec910 |
|
BLAKE2b-256 | 90f664a5ba3d435b407a9b4f1bdcd2012ac5a1503e4c4acb6e0801a70a735da6 |
Hashes for ruleopt-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a8d76e876eb784e7b156085693b7fe243d3f6c8dd5b5373023cb0cb55b50afc |
|
MD5 | 981c22f5d77f365ed3f87b261e19bddd |
|
BLAKE2b-256 | a03f31b3082cff5014a39bbdbecb6788c07408a0c69d7805046100c95ad79eb8 |
Hashes for ruleopt-1.0.1-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab24da860b3ae413888f4dd0fcb49858a3edd110e2f31d3e93a1246e7dc8af4b |
|
MD5 | ebe5cf4326e739e5859c76743c1dcff8 |
|
BLAKE2b-256 | 864dd57e10baed82f823db58c061fcf27940eb86606bc140b64bb4b424270600 |
Hashes for ruleopt-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88dfbfb9af46a6d4c75807871a0d7ca9a65f0cad12d122c9cd84e4caeb6d70a5 |
|
MD5 | e1d341dfe6cb0592723eabb9711735a4 |
|
BLAKE2b-256 | 504dfb370e25909e1abdac8da3675d4a138f1e688ca60f9467895cfcd7fb6836 |
Hashes for ruleopt-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d72e3c2a2187dffca74df71bec5dcfacd1823955c774da2489c624d8530b0420 |
|
MD5 | 57c55afd86eb27229907d821deecc195 |
|
BLAKE2b-256 | 4ddb4325162913f4e36a7497d007fa868af217793bec9b785a27eace85ebc073 |
Hashes for ruleopt-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27893641d8ce0f903853b0e39c2eaf8abd95c23642fe86d37eeee26da16ec799 |
|
MD5 | cd9b967b2c29c6278256f55126bbacb3 |
|
BLAKE2b-256 | ac30693279ee33cb1ea0398a96dac7dc9d62ea74c4bb8ff98a04bbd67f8ce635 |
Hashes for ruleopt-1.0.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 728e4298080535a7e16385e5255ed2919a2ef6a45d294e4cdddafa699f871d7f |
|
MD5 | 6b428f14ff93cf62c5c02d1f0ddc98aa |
|
BLAKE2b-256 | 31e565c5680276aa5361ed94b691a2400b660acce6405f7ea406ea2c959bd096 |
Hashes for ruleopt-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f95796b6271131a20f00d5c9e2d3d3300eb3cc94454da19cf997d79afb4a945 |
|
MD5 | d227bb4d5633e6272f9caa0e6a687e29 |
|
BLAKE2b-256 | 25149806debd5ce25e6c9425d6cd84a4fef706c83c04229c68c27178856ba088 |
Hashes for ruleopt-1.0.1-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ccd0838e5323da7fab818f2f1a4fdf0cf46536d97c734f73b6199979d8edc82 |
|
MD5 | 49ed5d7f421c97de7051154447d4fcad |
|
BLAKE2b-256 | f46dfba1c38871380e07b1a633efb7556db55a2181503edb0ad1c3c596ede08f |
Hashes for ruleopt-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a2bcc7db3319bc1f4e736d9b4d8fb91bfde75ca2f939d4495dab66a7039b0aa |
|
MD5 | 566cfce25220869164b9109d8409b95a |
|
BLAKE2b-256 | a377a56e2c5f9278fdf3af3afcf0f95c0e6c6b6e1a175b218610361b79826ccc |
Hashes for ruleopt-1.0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cded1d3043febcaf63f41442ab880e195280d90ec794586a3d3ff921b5b0fc3e |
|
MD5 | 7123710bf05e3d222081bfb205579e77 |
|
BLAKE2b-256 | f993cafb9f98221a2d1172f40773dd63ca30d6ffba4d3c83dd8f8b6e37b8e207 |
Hashes for ruleopt-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c930c94c402afc589b4f7e4ce4d84ff71d95cf9fd2f0ffc3737bd3f3e5f3bd18 |
|
MD5 | 49517a0cbb460b45186ea21791a2d4e0 |
|
BLAKE2b-256 | a1cca54e89969d617b19db606136807b6eaf8b0d4d85619e4ceb0ed72e9c1113 |
Hashes for ruleopt-1.0.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bf1edc5ee49f7c930f1c3e7dda689a878c7e6428f52728e7aaddcc5ab1c0726 |
|
MD5 | 919d947ed9d04d336d97eac0fd86e340 |
|
BLAKE2b-256 | e05ccf0f3739312e0d7394ca6a24698fcad849233e9805fdb8ff516fb44d59bd |
Hashes for ruleopt-1.0.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 078cdb3fc08d3751df4d1c19d95365c1bbbed58a359d67d758ff2c7beb1e1ae8 |
|
MD5 | 15167c5dd6af3c9a199735e7ecdeced5 |
|
BLAKE2b-256 | 56e20851912b55f7f92ed6c5b43aa56749cfacbdc7f69422854158d4978f12ba |
Hashes for ruleopt-1.0.1-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fbbe4f5fcd0a015af96440abc298ccbf237014f9bccafa7e0dcbbd8bc22ecbf |
|
MD5 | 47366439a887e5339fa94b500fd11c83 |
|
BLAKE2b-256 | e87e38f204faa846aa63573564056fd1f9a312b7dd0e0fad5dc85951a15d2603 |
Hashes for ruleopt-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 885f3ecb41a8f778a5561a99f8132353690ec865637de58a7a0c4d627e5a39c8 |
|
MD5 | 3b0068be8acdf8ba5a0a7fdb4a26de2a |
|
BLAKE2b-256 | 358044d019b40fde195153a54f412d40d9d0ed444f8eec76fb4328e626508bb7 |
Hashes for ruleopt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8ce91f3ca31d84bfc82aec749c93a35b3f5dce533e92ad9cf7de93c0dab4d28 |
|
MD5 | f664237e966afd990dc06a809d2a616a |
|
BLAKE2b-256 | db5126ccf214e26e16a29656ee849a3084800c67b481083f8f9df76033ab197d |
Hashes for ruleopt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ee56743ddddd9e0d02f7ce87c1fd4b4c83f2197b4292f2bf63a138a278cbdf9 |
|
MD5 | cec183af866808f4320b0bae3fc8c01b |
|
BLAKE2b-256 | d25b8989c9d801e3240c3f456f79c4bd9d06852338841b043b54904f63e046a9 |