ruleopt


Nameruleopt JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryOptimization-Based Rule Learning for Classification
upload_time2024-04-24 21:29:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseBSD 3-Clause License
keywords python data-science machine-learning linear-programming machine-learning-library explainable-ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://arxiv.org/abs/2104.10751).

 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:

```bash
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:


```python
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](https://ruleopt.readthedocs.io/en/latest/).

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ruleopt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "python, data-science, machine-learning, linear-programming, machine-learning-library, explainable-ai",
    "author": null,
    "author_email": "Ilker Birbil <sibirbil@gmail.com>, Nursen Aydin <nursenaydin@gmail.com>, Ozg\u00fcr Martin <ozgurmartin@gmail.com>, Samet Copur <sametcopur@yahoo.com>",
    "download_url": null,
    "platform": null,
    "description": "# RuleOpt\n## Optimization-Based Rule Learning for Classification\n\nRuleOpt 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](https://arxiv.org/abs/2104.10751).\n\n 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.\n\nHere are a few highlights of `ruleopt`:\n\n- **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.\n- **Interpretability**: Prioritizes model transparency by assigning costs to rules in order to achieve a desirable balance with accuracy.\n- **Integration with Machine Learning Libraries**: Facilitates smooth integration with well-known Python libraries `scikit-learn`, `LightGBM`, and `XGBoost`, and existing machine learning pipelines.\n- **Extensive Solver Support**: Supports a wide array of solvers, including _Gurobi_, _CPLEX_ and _OR-Tools_.\n\n### Installation \nTo install `ruleopt`, use the following pip command:\n\n```bash\npip install ruleopt\n```\n### Usage\n\nTo use `ruleopt`, you need to initialize the `ruleopt` class with your specific parameters and fit it to your data. Here's a basic example:\n\n\n```python\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.datasets import load_iris\n\nfrom ruleopt import RUGClassifier\nfrom ruleopt.rule_cost import Gini\nfrom ruleopt.solver import ORToolsSolver\n\n# Set a random state for reproducibility\nrandom_state = 42\n\n# Load the Iris dataset\nX, y = load_iris(return_X_y=True)\n\n# Split the dataset into training and testing sets\nX_train, X_test, y_train, y_test = train_test_split(\n    X, y, test_size=0.2, random_state=random_state\n)\n\n# Define tree parameters\ntree_parameters = {\"max_depth\": 3, \"class_weight\": \"balanced\"}\n\nsolver = ORToolsSolver()\nrule_cost = Gini()\n\n# Initialize the RUGClassifier with specific parameters\nrug = RUGClassifier(\n    solver=solver,\n    random_state=random_state,\n    max_rmp_calls=20,\n    rule_cost=rule_cost,\n    **tree_parameters,\n)\n\n# Fit the RUGClassifier to the training data\nrug.fit(X_train, y_train)\n\n# Predict the labels of the testing set\ny_pred = rug.predict(X_test)\n```\n### Documentation\nFor more detailed information about the API and advanced usage, please refer to the full  [documentation](https://ruleopt.readthedocs.io/en/latest/).\n\n### Contributing\nContributions are welcome! If you'd like to improve `ruleopt` or suggest new features, feel free to fork the repository and submit a pull request.\n\n### License\n`ruleopt` is released under the BSD 3-Clause License. See the LICENSE file for more details.\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "Optimization-Based Rule Learning for Classification",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://ruleopt.readthedocs.io/",
        "Repository": "https://github.com/sametcopur/ruleopt",
        "Tracker": "https://github.com/sametcopur/ruleopt/issues"
    },
    "split_keywords": [
        "python",
        " data-science",
        " machine-learning",
        " linear-programming",
        " machine-learning-library",
        " explainable-ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1cca54e89969d617b19db606136807b6eaf8b0d4d85619e4ceb0ed72e9c1113",
                "md5": "49517a0cbb460b45186ea21791a2d4e0",
                "sha256": "c930c94c402afc589b4f7e4ce4d84ff71d95cf9fd2f0ffc3737bd3f3e5f3bd18"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl",
            "has_sig": false,
            "md5_digest": "49517a0cbb460b45186ea21791a2d4e0",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.9",
            "size": 318805,
            "upload_time": "2024-04-24T21:29:56",
            "upload_time_iso_8601": "2024-04-24T21:29:56.953543Z",
            "url": "https://files.pythonhosted.org/packages/a1/cc/a54e89969d617b19db606136807b6eaf8b0d4d85619e4ceb0ed72e9c1113/ruleopt-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f993cafb9f98221a2d1172f40773dd63ca30d6ffba4d3c83dd8f8b6e37b8e207",
                "md5": "7123710bf05e3d222081bfb205579e77",
                "sha256": "cded1d3043febcaf63f41442ab880e195280d90ec794586a3d3ff921b5b0fc3e"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp310-cp310-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "7123710bf05e3d222081bfb205579e77",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.9",
            "size": 312190,
            "upload_time": "2024-04-24T21:28:05",
            "upload_time_iso_8601": "2024-04-24T21:28:05.835858Z",
            "url": "https://files.pythonhosted.org/packages/f9/93/cafb9f98221a2d1172f40773dd63ca30d6ffba4d3c83dd8f8b6e37b8e207/ruleopt-1.0.1-cp310-cp310-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31e565c5680276aa5361ed94b691a2400b660acce6405f7ea406ea2c959bd096",
                "md5": "6b428f14ff93cf62c5c02d1f0ddc98aa",
                "sha256": "728e4298080535a7e16385e5255ed2919a2ef6a45d294e4cdddafa699f871d7f"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "6b428f14ff93cf62c5c02d1f0ddc98aa",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.9",
            "size": 311109,
            "upload_time": "2024-04-24T21:29:45",
            "upload_time_iso_8601": "2024-04-24T21:29:45.364629Z",
            "url": "https://files.pythonhosted.org/packages/31/e5/65c5680276aa5361ed94b691a2400b660acce6405f7ea406ea2c959bd096/ruleopt-1.0.1-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac30693279ee33cb1ea0398a96dac7dc9d62ea74c4bb8ff98a04bbd67f8ce635",
                "md5": "cd9b967b2c29c6278256f55126bbacb3",
                "sha256": "27893641d8ce0f903853b0e39c2eaf8abd95c23642fe86d37eeee26da16ec799"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl",
            "has_sig": false,
            "md5_digest": "cd9b967b2c29c6278256f55126bbacb3",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9",
            "size": 318658,
            "upload_time": "2024-04-24T21:29:58",
            "upload_time_iso_8601": "2024-04-24T21:29:58.057651Z",
            "url": "https://files.pythonhosted.org/packages/ac/30/693279ee33cb1ea0398a96dac7dc9d62ea74c4bb8ff98a04bbd67f8ce635/ruleopt-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ddb4325162913f4e36a7497d007fa868af217793bec9b785a27eace85ebc073",
                "md5": "57c55afd86eb27229907d821deecc195",
                "sha256": "d72e3c2a2187dffca74df71bec5dcfacd1823955c774da2489c624d8530b0420"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp311-cp311-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "57c55afd86eb27229907d821deecc195",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9",
            "size": 311810,
            "upload_time": "2024-04-24T21:28:07",
            "upload_time_iso_8601": "2024-04-24T21:28:07.626501Z",
            "url": "https://files.pythonhosted.org/packages/4d/db/4325162913f4e36a7497d007fa868af217793bec9b785a27eace85ebc073/ruleopt-1.0.1-cp311-cp311-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90f664a5ba3d435b407a9b4f1bdcd2012ac5a1503e4c4acb6e0801a70a735da6",
                "md5": "885bb8cf8f35a638158fabd1b57ec910",
                "sha256": "53fb2c6e90004a449a4c8fe7a77e930aea802fa13d315180937e36b0571aab56"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp311-cp311-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "885bb8cf8f35a638158fabd1b57ec910",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9",
            "size": 311085,
            "upload_time": "2024-04-24T21:29:47",
            "upload_time_iso_8601": "2024-04-24T21:29:47.213798Z",
            "url": "https://files.pythonhosted.org/packages/90/f6/64a5ba3d435b407a9b4f1bdcd2012ac5a1503e4c4acb6e0801a70a735da6/ruleopt-1.0.1-cp311-cp311-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ede1b1ae989b7856ec1167f4b401b64cfae58c461383d2d559c87259a25a8660",
                "md5": "74c941400ec3580929fed2687e53688e",
                "sha256": "f0d89c21a91c80ab1807c4b5228746edbacd0efded7834761eb78036c7b958d0"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl",
            "has_sig": false,
            "md5_digest": "74c941400ec3580929fed2687e53688e",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.9",
            "size": 319401,
            "upload_time": "2024-04-24T21:29:59",
            "upload_time_iso_8601": "2024-04-24T21:29:59.837386Z",
            "url": "https://files.pythonhosted.org/packages/ed/e1/b1ae989b7856ec1167f4b401b64cfae58c461383d2d559c87259a25a8660/ruleopt-1.0.1-cp312-cp312-macosx_10_9_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a7fe9f20a70759e41438500328c906f936044efe8d77866097dd1c193299bb3",
                "md5": "5f9d4d315efd6ec7efa237b215d1b1f8",
                "sha256": "94f7ce213882e10992f1bf713058e1bffd34d9ae3f1c23a1c6b40b133d59f30a"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp312-cp312-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "5f9d4d315efd6ec7efa237b215d1b1f8",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.9",
            "size": 312367,
            "upload_time": "2024-04-24T21:28:09",
            "upload_time_iso_8601": "2024-04-24T21:28:09.281081Z",
            "url": "https://files.pythonhosted.org/packages/1a/7f/e9f20a70759e41438500328c906f936044efe8d77866097dd1c193299bb3/ruleopt-1.0.1-cp312-cp312-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89312c68d1de022cc25ab4a9c708df206d1d5b011d2ea867d8b785f4d107d391",
                "md5": "f383b914831b8e0930cb49a880845b9f",
                "sha256": "b6ef1e82701ae6012167002b982717ec22d4395f1864e2ec81fd57df416954d6"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp312-cp312-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "f383b914831b8e0930cb49a880845b9f",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.9",
            "size": 310021,
            "upload_time": "2024-04-24T21:29:48",
            "upload_time_iso_8601": "2024-04-24T21:29:48.977132Z",
            "url": "https://files.pythonhosted.org/packages/89/31/2c68d1de022cc25ab4a9c708df206d1d5b011d2ea867d8b785f4d107d391/ruleopt-1.0.1-cp312-cp312-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d25b8989c9d801e3240c3f456f79c4bd9d06852338841b043b54904f63e046a9",
                "md5": "cec183af866808f4320b0bae3fc8c01b",
                "sha256": "1ee56743ddddd9e0d02f7ce87c1fd4b4c83f2197b4292f2bf63a138a278cbdf9"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl",
            "has_sig": false,
            "md5_digest": "cec183af866808f4320b0bae3fc8c01b",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 319386,
            "upload_time": "2024-04-24T21:30:01",
            "upload_time_iso_8601": "2024-04-24T21:30:01.002470Z",
            "url": "https://files.pythonhosted.org/packages/d2/5b/8989c9d801e3240c3f456f79c4bd9d06852338841b043b54904f63e046a9/ruleopt-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db5126ccf214e26e16a29656ee849a3084800c67b481083f8f9df76033ab197d",
                "md5": "f664237e966afd990dc06a809d2a616a",
                "sha256": "c8ce91f3ca31d84bfc82aec749c93a35b3f5dce533e92ad9cf7de93c0dab4d28"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "f664237e966afd990dc06a809d2a616a",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 312801,
            "upload_time": "2024-04-24T21:28:11",
            "upload_time_iso_8601": "2024-04-24T21:28:11.042579Z",
            "url": "https://files.pythonhosted.org/packages/db/51/26ccf214e26e16a29656ee849a3084800c67b481083f8f9df76033ab197d/ruleopt-1.0.1-cp39-cp39-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e05ccf0f3739312e0d7394ca6a24698fcad849233e9805fdb8ff516fb44d59bd",
                "md5": "919d947ed9d04d336d97eac0fd86e340",
                "sha256": "9bf1edc5ee49f7c930f1c3e7dda689a878c7e6428f52728e7aaddcc5ab1c0726"
            },
            "downloads": -1,
            "filename": "ruleopt-1.0.1-cp39-cp39-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "919d947ed9d04d336d97eac0fd86e340",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 311690,
            "upload_time": "2024-04-24T21:29:50",
            "upload_time_iso_8601": "2024-04-24T21:29:50.824037Z",
            "url": "https://files.pythonhosted.org/packages/e0/5c/cf0f3739312e0d7394ca6a24698fcad849233e9805fdb8ff516fb44d59bd/ruleopt-1.0.1-cp39-cp39-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-24 21:29:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sametcopur",
    "github_project": "ruleopt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ruleopt"
}
        
Elapsed time: 0.25839s