{"id":13576100,"url":"https://github.com/sametcopur/ruleopt","last_synced_at":"2025-10-30T23:52:37.895Z","repository":{"id":229627234,"uuid":"777220156","full_name":"sametcopur/ruleopt","owner":"sametcopur","description":"Optimization-Based Rule Learning for Classification","archived":false,"fork":false,"pushed_at":"2025-10-03T10:39:02.000Z","size":242,"stargazers_count":48,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-03T12:09:43.363Z","etag":null,"topics":["data-science","explainable-ai","linear-programming","machine-learning","machine-learning-library","python"],"latest_commit_sha":null,"homepage":"https://ruleopt.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sametcopur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-25T12:46:53.000Z","updated_at":"2025-10-03T10:39:05.000Z","dependencies_parsed_at":"2024-04-21T15:10:45.245Z","dependency_job_id":"6bff7476-56fa-4fb8-adc4-87159e506355","html_url":"https://github.com/sametcopur/ruleopt","commit_stats":null,"previous_names":["sametcopur/ruleopt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sametcopur/ruleopt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sametcopur%2Fruleopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sametcopur%2Fruleopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sametcopur%2Fruleopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sametcopur%2Fruleopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sametcopur","download_url":"https://codeload.github.com/sametcopur/ruleopt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sametcopur%2Fruleopt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281902523,"owners_count":26581164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","explainable-ai","linear-programming","machine-learning","machine-learning-library","python"],"created_at":"2024-08-01T15:01:06.982Z","updated_at":"2025-10-30T23:52:37.890Z","avatar_url":"https://github.com/sametcopur.png","language":"Python","readme":"# 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 [journal paper](https://doi.org/10.1016/j.cor.2025.107163).\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n    \u003cimg width=\"50%\" src=\"./img/flow_chart.png\"\u003e \n\u003c/p\u003e\n\nThe 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\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","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsametcopur%2Fruleopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsametcopur%2Fruleopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsametcopur%2Fruleopt/lists"}